本文整理汇总了C#中System.Web.HttpRequestBase.BindingUrlStoreName方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestBase.BindingUrlStoreName方法的具体用法?C# HttpRequestBase.BindingUrlStoreName怎么用?C# HttpRequestBase.BindingUrlStoreName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpRequestBase
的用法示例。
在下文中一共展示了HttpRequestBase.BindingUrlStoreName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCurrentPage
public static Page GetCurrentPage(this StoreFront storeFront, HttpRequestBase request, bool throwErrorIfNotFound = true)
{
string url = request.Url.AbsolutePath.Trim('/').ToLower();
string appPath = request.ApplicationPath.Trim('/').ToLower();
//remove app path for virtual directories running
if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(appPath) && url.StartsWith(appPath))
{
url = url.Remove(0, appPath.Length).Trim('/');
}
string urlStoreName = request.BindingUrlStoreName();
if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(urlStoreName) && url.StartsWith("stores/" + urlStoreName))
{
url = url.Remove(0, ("stores/" + urlStoreName).Length).Trim('/');
}
url = "/" + url;
return storeFront.GetCurrentPage(url, throwErrorIfNotFound);
}
示例2: GetInactiveStoreBindingMatches
public static List<StoreBinding> GetInactiveStoreBindingMatches(this IGstoreDb db, HttpRequestBase request)
{
return db.GetInactiveStoreBindingMatches(request.BindingUrlStoreName(), request.BindingHostName(), request.BindingRootPath(), request.BindingPort());
}
示例3: 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);
}
示例4: 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
//.........这里部分代码省略.........