本文整理汇总了C#中IHttpRequest.GetApplicationUrl方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpRequest.GetApplicationUrl方法的具体用法?C# IHttpRequest.GetApplicationUrl怎么用?C# IHttpRequest.GetApplicationUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpRequest
的用法示例。
在下文中一共展示了IHttpRequest.GetApplicationUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
/// <summary>
/// Non ASP.NET requests
/// </summary>
/// <param name="request"></param>
/// <param name="response"></param>
/// <param name="operationName"></param>
public void ProcessRequest(IHttpRequest request, IHttpResponse response, string operationName)
{
if (string.IsNullOrEmpty(RelativeUrl) && string.IsNullOrEmpty(AbsoluteUrl))
throw new ArgumentNullException("RelativeUrl or AbsoluteUrl");
if (!string.IsNullOrEmpty(AbsoluteUrl))
{
response.StatusCode = (int)HttpStatusCode.Redirect;
response.AddHeader(HttpHeaders.Location, this.AbsoluteUrl);
}
else
{
var absoluteUrl = request.GetApplicationUrl();
if (!string.IsNullOrEmpty(RelativeUrl))
{
if (this.RelativeUrl.StartsWith("/"))
absoluteUrl = absoluteUrl.CombineWith(this.RelativeUrl);
else if (this.RelativeUrl.StartsWith("~/"))
absoluteUrl = absoluteUrl.CombineWith(this.RelativeUrl.Replace("~/", ""));
else
absoluteUrl = request.AbsoluteUri.CombineWith(this.RelativeUrl);
}
response.StatusCode = (int)HttpStatusCode.Redirect;
response.AddHeader(HttpHeaders.Location, absoluteUrl);
}
response.EndHttpRequest(skipClose:true);
}
开发者ID:grammarware,项目名称:fodder,代码行数:34,代码来源:src_ServiceStack_WebHost_Endpoints_Support_RedirectHttpHandler.cs
示例2: CalculateAppUrl
private string CalculateAppUrl(IHttpRequest request, string aspnetSubPath)
{
string serviceStackUrl = request.GetApplicationUrl();
if (!SupportWebApplication)
return serviceStackUrl; //Like version 1.0.4
if (serviceStackUrl.Equals(aspnetSubPath))
return serviceStackUrl;
if (aspnetSubPath != null && serviceStackUrl.StartsWith(aspnetSubPath))
return serviceStackUrl;
string newUrl;
if (TryBuildNewUrl(serviceStackUrl, aspnetSubPath, out newUrl))
return newUrl;
return serviceStackUrl;
}