当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestBase.BindingHostName方法代码示例

本文整理汇总了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;
        }
开发者ID:berlstone,项目名称:GStore,代码行数:48,代码来源:SeedDataExtensions.cs

示例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());
 }
开发者ID:berlstone,项目名称:GStore,代码行数:5,代码来源:StoreFrontExtensions.cs

示例3: GetInactiveStoreBindingMatches

 public static List<StoreBinding> GetInactiveStoreBindingMatches(this IGstoreDb db, HttpRequestBase request)
 {
     return db.GetInactiveStoreBindingMatches(request.BindingUrlStoreName(), request.BindingHostName(), request.BindingRootPath(), request.BindingPort());
 }
开发者ID:berlstone,项目名称:GStore,代码行数:4,代码来源:StoreFrontExtensions.cs

示例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);
 }
开发者ID:berlstone,项目名称:GStore,代码行数:20,代码来源:StoreFrontExtensions.cs

示例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
//.........这里部分代码省略.........
开发者ID:berlstone,项目名称:GStore,代码行数:101,代码来源:StoreFrontExtensions.cs


注:本文中的System.Web.HttpRequestBase.BindingHostName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。