本文整理汇总了C#中System.Web.HttpRequestBase.BindingHostName方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestBase.BindingHostName方法的具体用法?C# HttpRequestBase.BindingHostName怎么用?C# HttpRequestBase.BindingHostName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpRequestBase
的用法示例。
在下文中一共展示了HttpRequestBase.BindingHostName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAutoHomePage
public static Page CreateAutoHomePage(this IGstoreDb db, HttpRequestBase request, StoreFrontConfiguration storeFrontConfig, GStoreData.ControllerBase.BaseController baseController)
{
if (db == null)
{
throw new ArgumentNullException("db");
}
if (request == null)
{
throw new ArgumentNullException("request");
}
if (baseController == null)
{
throw new ArgumentNullException("baseController");
}
if (storeFrontConfig == null)
{
throw new ArgumentNullException("storeFrontConfig");
}
UserProfile userProfile = db.SeedAutoMapUserBestGuess();
db.CachedStoreFront = null;
db.CachedUserProfile = userProfile;
db.UserName = userProfile.UserName;
PageTemplate pageTemplate = null;
if (!db.PageTemplates.IsEmpty())
{
pageTemplate = db.PageTemplates.Where(pt => pt.ClientId == storeFrontConfig.ClientId).ApplyDefaultSort().FirstOrDefault();
}
else
{
//no page templates in database, create seed one
pageTemplate = db.CreateSeedPageTemplate(Settings.AppDefaultPageTemplateName, Settings.AppDefaultPageTemplateViewName, storeFrontConfig.Client);
}
Page page = db.CreateSeedPage(storeFrontConfig.Name, storeFrontConfig.Name, "/", 1000, storeFrontConfig, pageTemplate, true);
string message = "--Auto-Created Home Page for StoreFront '" + storeFrontConfig.Name + "' [" + storeFrontConfig.StoreFrontId + "]"
+ " For HostName: " + request.BindingHostName() + " Port: " + request.BindingPort() + " RootPath: " + request.BindingRootPath()
+ " From RawUrl: " + request.RawUrl + " QueryString: " + request.QueryString + " ContentLength: " + request.ContentLength
+ " HTTPMethod: " + request.HttpMethod + " Client IP: " + request.UserHostAddress;
System.Diagnostics.Trace.WriteLine(message);
EventLogExtensions.LogSystemEvent(db, baseController.HttpContext, baseController.RouteData, baseController.RouteData.ToSourceString(), SystemEventLevel.Information, message, string.Empty, string.Empty, string.Empty, baseController);
return page;
}
示例2: GetCurrentStoreBindingOrNull
public static StoreBinding GetCurrentStoreBindingOrNull(this IGstoreDb db, HttpRequestBase request)
{
string urlStoreName = request.RequestContext.RouteData.UrlStoreName();
return db.GetCurrentStoreBindingOrNull(urlStoreName, request.BindingHostName(), request.BindingRootPath(), request.BindingPort());
}
示例3: GetInactiveStoreBindingMatches
public static List<StoreBinding> GetInactiveStoreBindingMatches(this IGstoreDb db, HttpRequestBase request)
{
return db.GetInactiveStoreBindingMatches(request.BindingUrlStoreName(), request.BindingHostName(), request.BindingRootPath(), request.BindingPort());
}
示例4: SetDefaultsForNew
public static void SetDefaultsForNew(this StoreBinding storeBinding, HttpRequestBase request, int? clientId, int? storeFrontId)
{
if (clientId.HasValue)
{
storeBinding.ClientId = clientId.Value;
}
if (storeFrontId.HasValue)
{
storeBinding.StoreFrontId = storeFrontId.Value;
}
storeBinding.Order = 1000;
storeBinding.HostName = request.BindingHostName();
storeBinding.Port = request.BindingPort();
storeBinding.RootPath = request.BindingRootPath();
storeBinding.UrlStoreName = request.BindingUrlStoreName();
storeBinding.UseUrlStoreName = !string.IsNullOrEmpty(storeBinding.UrlStoreName);
storeBinding.IsPending = false;
storeBinding.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
storeBinding.EndDateTimeUtc = DateTime.UtcNow.AddYears(100);
}
示例5: GetCurrentStoreFrontConfig
/// <summary>
/// Gets the current store front, or null if anonymous; uses CachedStoreFront from context if available
/// </summary>
/// <param name="db"></param>
/// <param name="request"></param>
/// <param name="throwErrorIfNotFound">If true, throws an error when storefront is not found</param>
/// <returns></returns>
public static StoreFrontConfiguration GetCurrentStoreFrontConfig(this IGstoreDb db, HttpRequestBase request, bool throwErrorIfNotFound, bool returnInactiveIfFound)
{
//if context has already set the current store front, return it
if (db.CachedStoreFrontConfig != null)
{
//note: only active storefront is cached, inactives are always queried from database
return db.CachedStoreFrontConfig;
}
if (db.CachedStoreFront != null && db.CachedStoreFrontConfig == null)
{
//storefront is set, but not config, try to get current config
StoreFrontConfiguration storeFrontActiveCurrentConfig = db.CachedStoreFront.CurrentConfig();
if (storeFrontActiveCurrentConfig != null)
{
db.CachedStoreFrontConfig = storeFrontActiveCurrentConfig;
return storeFrontActiveCurrentConfig;
}
}
if (request == null)
{
if (throwErrorIfNotFound)
{
throw new ApplicationException("Request context is null, cannot get current store front");
}
return null;
}
//verify database has been seeded and not blank
if (db.StoreBindings.IsEmpty())
{
if (throwErrorIfNotFound)
{
string error = "No Store bindings in database.";
if (db.StoreFronts.IsEmpty())
{
error = "No Store Fronts in database. Be sure database is seeded or force a seed of the database." + "\n" + error;
}
if (db.Clients.IsEmpty())
{
error = "No Clients in database. Be sure database is seeded or force a seed of the database." + "\n" + error;
}
if (Settings.AppDoNotSeedDatabase)
{
error += "\nSettings.AppDoNotSeedDatabase = true. Change this settings to false to allow the system to seed the database with client and store front data.";
}
throw new Exceptions.NoMatchingBindingException(error, request.Url);
}
return null;
}
StoreBinding activeStoreBinding = db.GetCurrentStoreBindingOrNull(request);
if (activeStoreBinding != null)
{
//active match found, update cache and return the active match
db.CachedStoreFront = activeStoreBinding.StoreFront;
db.CachedStoreFrontConfig = activeStoreBinding.StoreFrontConfiguration;
return activeStoreBinding.StoreFrontConfiguration;
}
if ((throwErrorIfNotFound == false) && (returnInactiveIfFound == false))
{
//if throwErrorIfNotFound = false (means no error throw)
//and
//if returnInactiveIfFound = false (means I don't want an inactive record
//so: if we're not throwing an exception and we're not returning an inactive, just quit with null
return null;
}
string errorMessage = "No match found in active store bindings.\n"
+ " \n BindingHostName: " + request.BindingHostName()
+ " \n BindingRootPath:" + request.BindingRootPath()
+ " \n BindingPort:" + request.BindingPort().ToString()
+ " \n UrlStoreName: " + request.BindingUrlStoreName()
+ " \n RawUrl: " + request.RawUrl
+ " \n IP Address: " + request.UserHostAddress
+ "\n You may want to add a binding catch-all such as HostName=*, RootPath=*, Port=0";
//why can't we find an active binding? get inactive matches to find if it's an inactive record
List<StoreBinding> inactiveBindings = db.GetInactiveStoreBindingMatches(request);
if (inactiveBindings.Count == 0)
{
//No match in the database for this host name, root path, and port.
//throw error to show ("no store page: GStoreNotFound.html") applies also to hostname hackers and spoofs with host headers
errorMessage = "Error! StoreFront not found. \nNo StoreBindings match the current host name, port, and RootPath.\n"
+ "\n No matching bindings found in the inactive records. This is an unhandled URL or a hostname hack."
+ "\n\n" + errorMessage;
//we could not find an inactive record, so throw a no match exception or return null if throwErrorIfNotFound = false
//.........这里部分代码省略.........