本文整理汇总了C#中IRequest.GetBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:C# IRequest.GetBaseUrl方法的具体用法?C# IRequest.GetBaseUrl怎么用?C# IRequest.GetBaseUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRequest
的用法示例。
在下文中一共展示了IRequest.GetBaseUrl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapReferences
public static Crawler MapReferences(this Crawler crawler, IRequest request)
{
crawler.References = new CrawlerRefs
{
CrawlerRef = request.GetBaseUrl().CombineWith(new FetchCrawler { Id = crawler.Id }.ToGetUrl()),
DivisionRef = request.GetBaseUrl().CombineWith(new FetchDivision { Id = crawler.DivisionId }.ToGetUrl()),
ServerRef = request.GetBaseUrl().CombineWith(new FetchServer { Id = crawler.ServerId }.ToGetUrl())
};
return crawler;
}
示例2: Execute
public void Execute(IRequest httpReq, IResponse httpRes)
{
HostContext.AppHost.AssertFeatures(Feature.Metadata);
httpRes.ContentType = "text/xml";
var baseUri = httpReq.GetParentBaseUrl();
var optimizeForFlash = httpReq.QueryString["flash"] != null;
var operations = new XsdMetadata(HostContext.Metadata, flash: optimizeForFlash);
try
{
var wsdlTemplate = GetWsdlTemplate(operations, baseUri, optimizeForFlash, httpReq.GetBaseUrl(), HostContext.Config.SoapServiceName);
var wsdl = HostContext.AppHost.GenerateWsdl(wsdlTemplate);
httpRes.Write(wsdl);
}
catch (Exception ex)
{
log.Error("Autogeneration of WSDL failed.", ex);
httpRes.Write("Autogenerated WSDLs are not supported "
+ (Env.IsMono ? "on Mono" : "with this configuration"));
}
}
示例3: GetRequestInfo
public static RequestInfoResponse GetRequestInfo(IRequest httpReq)
{
int virtualPathCount = 0;
int.TryParse(httpReq.QueryString["virtualPathCount"], out virtualPathCount);
var hostType = HostContext.AppHost.GetType();
var response = new RequestInfoResponse
{
Usage = "append '?debug=requestinfo' to any querystring. Optional params: virtualPathCount",
Host = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName,
HostType = "{0} ({1})".Fmt(HostContext.IsAspNetHost ? "ASP.NET" : "SelfHost", hostType.BaseType != null ? hostType.BaseType.Name : hostType.Name),
Date = DateTime.UtcNow.ToString("yy-MM-dd HH:mm:ss"),
ServiceName = HostContext.ServiceName,
HandlerFactoryPath = HostContext.Config.HandlerFactoryPath,
UserHostAddress = httpReq.UserHostAddress,
HttpMethod = httpReq.Verb,
AbsoluteUri = httpReq.AbsoluteUri,
WebHostUrl = HostContext.Config.WebHostUrl,
ApplicationBaseUrl = httpReq.GetBaseUrl(),
ResolveAbsoluteUrl = HostContext.AppHost.ResolveAbsoluteUrl("~/resolve", httpReq),
RootDirectoryPath = HostContext.VirtualFileSources.RootDirectory.RealPath,
StripApplicationVirtualPath = HostContext.Config.StripApplicationVirtualPath,
CurrentDirectory = Directory.GetCurrentDirectory(),
RawUrl = httpReq.RawUrl,
ResolvedPathInfo = httpReq.PathInfo,
ContentType = httpReq.ContentType,
Headers = ToDictionary(httpReq.Headers),
QueryString = ToDictionary(httpReq.QueryString),
FormData = ToDictionary(httpReq.FormData),
AcceptTypes = new List<string>(httpReq.AcceptTypes ?? new string[0]),
ContentLength = httpReq.ContentLength,
OperationName = httpReq.OperationName,
ResponseContentType = httpReq.ResponseContentType,
PluginsLoaded = HostContext.AppHost.PluginsLoaded,
StartUpErrors = HostContext.AppHost.StartUpErrors,
LastRequestInfo = LastRequestInfo,
VirtualPathProviderFiles = HostContext.AppHost.VirtualFileSources.GetAllMatchingFiles("*").Take(virtualPathCount).Map(x => x.RealPath),
Stats = new Dictionary<string, string> {
{"RawHttpHandlers", HostContext.AppHost.RawHttpHandlers.Count.ToString() },
{"PreRequestFilters", HostContext.AppHost.PreRequestFilters.Count.ToString() },
{"RequestBinders", HostContext.AppHost.RequestBinders.Count.ToString() },
{"GlobalRequestFilters", HostContext.AppHost.GlobalRequestFilters.Count.ToString() },
{"GlobalResponseFilters", HostContext.AppHost.GlobalResponseFilters.Count.ToString() },
{"CatchAllHandlers", HostContext.AppHost.CatchAllHandlers.Count.ToString() },
{"Plugins", HostContext.AppHost.Plugins.Count.ToString() },
{"ViewEngines", HostContext.AppHost.ViewEngines.Count.ToString() },
{"RequestTypes", HostContext.AppHost.Metadata.RequestTypes.Count.ToString() },
{"ResponseTypes", HostContext.AppHost.Metadata.ResponseTypes.Count.ToString() },
{"ServiceTypes", HostContext.AppHost.Metadata.ServiceTypes.Count.ToString() },
{"RestPaths", HostContext.AppHost.RestPaths.Count.ToString() },
{"ContentTypes", HostContext.AppHost.ContentTypes.ContentTypeFormats.Count.ToString() },
{"EnableFeatures", HostContext.Config.EnableFeatures.ToString() },
{"VirtualPathProvider", HostContext.AppHost.VirtualFileSources.ToString() }
},
};
return response;
}
示例4: GetRequestInfo
public static RequestInfoResponse GetRequestInfo(IRequest httpReq)
{
var response = new RequestInfoResponse
{
Usage = "append '?debug=requestinfo' to any querystring",
Host = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName,
Date = DateTime.UtcNow,
ServiceName = HostContext.ServiceName,
HandlerFactoryPath = HostContext.Config.HandlerFactoryPath,
UserHostAddress = httpReq.UserHostAddress,
HttpMethod = httpReq.Verb,
AbsoluteUri = httpReq.AbsoluteUri,
WebHostUrl = HostContext.Config.WebHostUrl,
ApplicationBaseUrl = httpReq.GetBaseUrl(),
ResolveAbsoluteUrl = HostContext.AppHost.ResolveAbsoluteUrl("~/resolve", httpReq),
StripApplicationVirtualPath = HostContext.Config.StripApplicationVirtualPath,
RawUrl = httpReq.RawUrl,
ResolvedPathInfo = httpReq.PathInfo,
ContentType = httpReq.ContentType,
Headers = ToDictionary(httpReq.Headers),
QueryString = ToDictionary(httpReq.QueryString),
FormData = ToDictionary(httpReq.FormData),
AcceptTypes = new List<string>(httpReq.AcceptTypes ?? new string[0]),
ContentLength = httpReq.ContentLength,
OperationName = httpReq.OperationName,
ResponseContentType = httpReq.ResponseContentType,
PluginsLoaded = HostContext.AppHost.PluginsLoaded,
StartUpErrors = HostContext.AppHost.StartUpErrors,
LastRequestInfo = LastRequestInfo,
VirtualPathProviderFiles = HostContext.AppHost.VirtualPathProvider.GetAllMatchingFiles("*").Take(1000).Map(x => x.RealPath),
Stats = new Dictionary<string, string> {
{"RawHttpHandlers", HostContext.AppHost.RawHttpHandlers.Count.ToString() },
{"PreRequestFilters", HostContext.AppHost.PreRequestFilters.Count.ToString() },
{"RequestBinders", HostContext.AppHost.RequestBinders.Count.ToString() },
{"GlobalRequestFilters", HostContext.AppHost.GlobalRequestFilters.Count.ToString() },
{"GlobalResponseFilters", HostContext.AppHost.GlobalResponseFilters.Count.ToString() },
{"CatchAllHandlers", HostContext.AppHost.CatchAllHandlers.Count.ToString() },
{"Plugins", HostContext.AppHost.Plugins.Count.ToString() },
{"ViewEngines", HostContext.AppHost.ViewEngines.Count.ToString() },
{"RequestTypes", HostContext.AppHost.Metadata.RequestTypes.Count.ToString() },
{"ResponseTypes", HostContext.AppHost.Metadata.ResponseTypes.Count.ToString() },
{"ServiceTypes", HostContext.AppHost.Metadata.ServiceTypes.Count.ToString() },
{"RestPaths", HostContext.AppHost.RestPaths.Count.ToString() },
{"ContentTypes", HostContext.AppHost.ContentTypes.ContentTypeFormats.Count.ToString() },
{"EnableFeatures", HostContext.Config.EnableFeatures.ToString() },
{"VirtualPathProvider", HostContext.AppHost.VirtualPathProvider.ToString() }
},
};
return response;
}