本文整理汇总了C#中Microsoft.AspNet.Http.HttpRequest类的典型用法代码示例。如果您正苦于以下问题:C# HttpRequest类的具体用法?C# HttpRequest怎么用?C# HttpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpRequest类属于Microsoft.AspNet.Http命名空间,在下文中一共展示了HttpRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateValueProviderAsync
private static async Task<IValueProvider> CreateValueProviderAsync(HttpRequest request)
{
return new FormValueProvider(
BindingSource.Form,
await request.ReadFormAsync(),
CultureInfo.CurrentCulture);
}
开发者ID:phinq19,项目名称:git_example,代码行数:7,代码来源:FormValueProviderFactory.cs
示例2: TryGetApiKey
private static bool TryGetApiKey(HttpRequest request, out string apiKey)
{
StringValues headerValue;
if (request.Headers.TryGetValue("Authorization", out headerValue))
{
AuthenticationHeaderValue authHeaderValue;
if (AuthenticationHeaderValue.TryParse(headerValue, out authHeaderValue))
{
apiKey = authHeaderValue.Parameter;
return true;
}
}
if (request.Headers.TryGetValue("X-Octopus-ApiKey", out headerValue))
{
apiKey = headerValue;
return true;
}
if (request.Headers.TryGetValue("X-NuGet-ApiKey", out headerValue))
{
apiKey = headerValue;
return true;
}
if (request.Query.ContainsKey("apikey"))
{
apiKey = request.Query["apikey"];
return true;
}
apiKey = null;
return false;
}
开发者ID:Zywave,项目名称:OctopusDeploy-Kraken,代码行数:34,代码来源:ApiKeyMiddleware.cs
示例3: CreateValueProviderAsync
private static async Task<IValueProvider> CreateValueProviderAsync(HttpRequest request)
{
return new JQueryFormValueProvider(
BindingSource.Form,
await GetValueCollectionAsync(request),
CultureInfo.CurrentCulture);
}
开发者ID:huoxudong125,项目名称:Mvc,代码行数:7,代码来源:JQueryFormValueProviderFactory.cs
示例4: ApplyQueryOptions
public virtual object ApplyQueryOptions(object value, HttpRequest request, ActionDescriptor descriptor)
{
var elementClrType = TypeHelper.GetImplementedIEnumerableType(value.GetType());
var model = request.ODataProperties().Model;
if (model == null)
{
throw Error.InvalidOperation(SRResources.QueryGetModelMustNotReturnNull);
}
var queryContext = new ODataQueryContext(
model,
elementClrType,
request.ODataProperties().Path);
var queryOptions = new ODataQueryOptions(queryContext, request);
var enumerable = value as IEnumerable;
if (enumerable == null)
{
// response is single entity.
return value;
}
// response is a collection.
var query = (value as IQueryable) ?? enumerable.AsQueryable();
return queryOptions.ApplyTo(query,
new ODataQuerySettings
{
HandleNullPropagation = HandleNullPropagationOption.True
});
}
开发者ID:genusP,项目名称:WebApi,代码行数:32,代码来源:EnableQueryAttribute.cs
示例5: Log
/*
* Very simple logger that logs to the VS Debug output window. Requires the debugger to be attached to work!
*/
public void Log(HttpRequest request, Exception ex)
{
/*
* Simplification due to time restrictions.
*/
Log(ex);
}
开发者ID:MarcusParkkinen,项目名称:artist-lookup-service,代码行数:11,代码来源:ConsoleLogger.cs
示例6: Combine
public static string Combine(HttpRequest request, string path, params Descriptor[] descriptors)
{
StringBuilder result = new StringBuilder();
foreach (Descriptor descriptor in descriptors)
{
if (!descriptor.Skip)
{
string value = descriptor.TakeFromUrl ? request.Query[descriptor.Name] : descriptor.Value;
if (!string.IsNullOrEmpty(value))
result.AppendFormat("{0}{1}={2}", result.Length == 0 ? '?' : '&', descriptor.Name, value);
}
}
foreach (KeyValuePair<string, string[]> keyValuePair in request.Query)
{
if (!descriptors.Any(d => d.Name == keyValuePair.Key))
{
string value = request.Query[keyValuePair.Key];
if (!string.IsNullOrEmpty(value))
result.AppendFormat("{0}{1}={2}", result.Length == 0 ? '?' : '&', keyValuePair.Key, value);
}
}
result.Insert(0, string.IsNullOrEmpty(path) ? request.Path.ToString() : path);
return result.ToString();
}
开发者ID:OlegDokuka,项目名称:Platformus,代码行数:29,代码来源:Url.cs
示例7: ODataQueryOptions
/// <summary>
/// Initializes a new instance of the <see cref="ODataQueryOptions"/> class based on the incoming request and some metadata information from
/// the <see cref="ODataQueryContext"/>.
/// </summary>
/// <param name="context">The <see cref="ODataQueryContext"/> which contains the <see cref="IEdmModel"/> and some type information.</param>
/// <param name="request">The incoming request message.</param>
public ODataQueryOptions(ODataQueryContext context, HttpRequest request)
{
if (context == null)
{
throw Error.ArgumentNull("context");
}
if (request == null)
{
throw Error.ArgumentNull("request");
}
_assemblyProvider = request.AssemblyProvider();
Context = context;
Request = request;
RawValues = new ODataRawQueryOptions();
var queryOptionDict = request.Query.ToDictionary(p => p.Key, p => p.Value.FirstOrDefault());
_queryOptionParser = new ODataQueryOptionParser(
context.Model,
context.ElementType,
context.NavigationSource,
queryOptionDict);
BuildQueryOptions(queryOptionDict);
}
开发者ID:emreolgun,项目名称:WebApi,代码行数:33,代码来源:ODataQueryOptions.cs
示例8: ParseAuthenticationHeader
private static bool ParseAuthenticationHeader(MgHttpRequestParam param, HttpRequest request)
{
//This method decodes and extracts the username and password from the http authentication
//header (if it exists) and packs the values into the MgHttpRequestParam object if they
//exist
String auth = request.Headers["authorization"];
if (auth != null && auth.Length > 6)
{
auth = auth.Substring(6);
byte[] decoded = Convert.FromBase64String(auth);
String decodedStr = Encoding.UTF8.GetString(decoded);
String[] decodedTokens = decodedStr.Split(':');
if (decodedTokens.Length == 1 || decodedTokens.Length == 2)
{
String username = decodedTokens[0];
String password = "";
if (decodedTokens.Length == 2)
password = decodedTokens[1];
param.AddParameter("USERNAME", username);
param.AddParameter("PASSWORD", password);
return true;
}
}
return false;
}
开发者ID:jumpinjackie,项目名称:mapguide-mvc6-sample,代码行数:26,代码来源:MapAgentController.cs
示例9: OnReceived
protected override async Task OnReceived(HttpRequest request, string connectionId, string data) {
var identity = request.HttpContext.User.Identity;
var status = identity.IsAuthenticated ? "authenticated" : "unauthenticated";
var name = identity.IsAuthenticated ? identity.Name : "client";
await Connection.Send(connectionId, $"Received an {status} message from {name}: {data}");
}
开发者ID:DovydasNavickas,项目名称:AspNet.Security.OpenIdConnect.Samples,代码行数:7,代码来源:SimpleConnection.cs
示例10: GetBasicAuth
public BasicAuthIdentity GetBasicAuth(HttpRequest request)
{
BasicAuthIdentity identity = null;
var headerValue = request.Headers["Authorization"];
if (!String.IsNullOrEmpty(headerValue))
{
var headerValues = headerValue.Split(' ');
var scheme = headerValues[0];
if (string.Compare(scheme, "Basic", true) == 0)
{
var encodedUsernameAndPassword = headerValues[1];
var usernameAndPassword = Encoding.UTF8.GetString(Convert.FromBase64String(encodedUsernameAndPassword));
if (usernameAndPassword != null && usernameAndPassword != ":")
{
var tokens = usernameAndPassword.Split(':');
switch (tokens.Length)
{
case 2:
identity = new BasicAuthIdentity(tokens[0], tokens[1]);
break;
case 1:
identity = new BasicAuthIdentity(tokens[0], null);
break;
default:
identity = null;
break;
}
}
}
}
return identity;
}
开发者ID:mbelles,项目名称:web-api-401s,代码行数:34,代码来源:BasicAuth.cs
示例11: RequestingSwaggerUi
private bool RequestingSwaggerUi(HttpRequest request)
{
if (request.Method != "GET") return false;
var routeValues = _requestMatcher.Match(request.Path);
return (routeValues != null);
}
开发者ID:mcliment,项目名称:Ahoy,代码行数:7,代码来源:SwaggerUiMIddleware.cs
示例12: RequestingSwaggerUi
private bool RequestingSwaggerUi(HttpRequest request)
{
if (request.Method != "GET") return false;
var routeValues = _requestMatcher.Match(request.Path.ToUriComponent().Trim('/'));
return (routeValues != null);
}
开发者ID:aytacozkan,项目名称:Ahoy,代码行数:7,代码来源:SwaggerUiMIddleware.cs
示例13: OnDisconnected
protected override Task OnDisconnected(HttpRequest request, string connectionId, bool stopCalled)
{
string ignored;
_users.TryRemove(connectionId, out ignored);
string suffix = stopCalled ? "cleanly" : "uncleanly";
return Connection.Broadcast(DateTime.Now + ": " + GetUser(connectionId) + " disconnected " + suffix);
}
开发者ID:eduaglz,项目名称:SignalR-Server,代码行数:8,代码来源:RawConnection.cs
示例14: RequestPrefersReturnNoContent
internal static bool RequestPrefersReturnNoContent(HttpRequest request)
{
string[] preferences = null;
if (request.Headers.TryGetValue(PreferHeaderName, out preferences))
{
return preferences.Contains(ReturnNoContentHeaderValue);
}
return false;
}
开发者ID:genusP,项目名称:WebApi,代码行数:9,代码来源:RequestPreferenceHelpers.cs
示例15: OrderedFileSet
public OrderedFileSet(IEnumerable<IWebFile> files,
FileSystemHelper fileSystemHelper,
HttpRequest request,
PreProcessPipeline defaultPipeline)
{
_files = files;
_defaultPipeline = defaultPipeline;
_fileSystemHelper = fileSystemHelper;
_request = request;
}
开发者ID:eByte23,项目名称:Smidge,代码行数:10,代码来源:OrderedFileSet.cs
示例16: GetStandardRedirectUri
/// <summary>
/// Get a redirect uri using standard options
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
private static string GetStandardRedirectUri(HttpRequest request)
{
var uri = new UriBuilder();
uri.Scheme = "https";
uri.Host = RemovePort.Replace(request.Host.Value, String.Empty);
uri.Path = request.Path.Value;
uri.Query = request.QueryString.Value;
return uri.ToString();
}
开发者ID:jnonce,项目名称:jnonce.AspNet.Hsts,代码行数:15,代码来源:HstsRedirectProvider.cs
示例17: CreateStreamDiscovery
private IStreamDiscovery CreateStreamDiscovery(HttpRequest request)
{
var streams = request.Query["streams"];
if( streams.FirstOrDefault() != null)
{
return new StaticStreamDiscovery(streams.Select(uri=>uri.Trim()));
}
var cluster = request.Query["cluster"].FirstOrDefault();
return new EtcdStreamDiscovery(cluster);
}
开发者ID:Zenasoft,项目名称:Jellyfish.EventsAggregator,代码行数:11,代码来源:EventsAggregator.cs
示例18: GetRequestPreferHeader
internal static string GetRequestPreferHeader(HttpRequest request)
{
string[] values;
if (request.Headers.TryGetValue(PreferHeaderName, out values))
{
// If there are many "Prefer" headers, pick up the first one.
return values.FirstOrDefault();
}
return null;
}
开发者ID:genusP,项目名称:WebApi,代码行数:11,代码来源:RequestPreferenceHelpers.cs
示例19: RequestingSwaggerDocs
private bool RequestingSwaggerDocs(HttpRequest request, out string apiVersion)
{
apiVersion = null;
if (request.Method != "GET") return false;
var routeValues = _requestMatcher.Match(request.Path.ToUriComponent().Trim('/'));
if (routeValues == null || !routeValues.ContainsKey("apiVersion")) return false;
apiVersion = routeValues["apiVersion"].ToString();
return true;
}
开发者ID:serkanpektas,项目名称:Ahoy,代码行数:11,代码来源:SwaggerDocsMIddleware.cs
示例20: GetHeaderInformation
public static string GetHeaderInformation(HttpRequest request)
{
var sb = new StringBuilder();
IHeaderDictionary headers = request.Headers;
foreach (var header in request.Headers)
{
sb.Append(GetDiv(header.Key, string.Join("; ", header.Value)));
}
return sb.ToString();
}
开发者ID:CNinnovation,项目名称:TechConference2016,代码行数:11,代码来源:RequestAndResponseSample.cs
注:本文中的Microsoft.AspNet.Http.HttpRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论