protected static void RedirectWithLanguage( System.Web.HttpContextBase context, string urlNonlocalized, string langtag, IUrlLocalizer m_urlLocalizer) { // Construct localized URL. string urlNew = m_urlLocalizer.SetLangTagInUrlPath(context, urlNonlocalized, UriKind.Relative, langtag); // Redirect user agent to new local URL. if (LocalizedApplication.Current.PermanentRedirects) { context.Response.StatusCode = 301; context.Response.Status = "301 Moved Permanently"; } else { context.Response.StatusCode = 302; context.Response.Status = "302 Moved Temporarily"; } context.Response.RedirectLocation = urlNew; // End the request early: no further processing along the pipeline. // NB: we did originally use context.Response.End(); here but that causes an // unnecessary exception to be thrown (https://support.microsoft.com/en-us/kb/312629) (#195) // NB: the line AFTER this line will execute, so best to return immediately here // and from caller etc.. context.ApplicationInstance.CompleteRequest(); }
public DefaultRootServices() { // Use Lazy to delay the creation of objects to when a request is being processed. // When initializing the app thehi may throw "Request is not available in this context" from WebConfigService translationRepository = new Lazy <POTranslationRepository>(() => new POTranslationRepository(new i18nSettings(new WebConfigSettingService()))); urlLocalizer = new UrlLocalizer(); textLocalizer = new Lazy <TextLocalizer>(() => new TextLocalizer(new i18nSettings(new WebConfigSettingService()), TranslationRepositoryForApp)); earlyUrlLocalizer = new EarlyUrlLocalizer(urlLocalizer); nuggetLocalizer = new Lazy <NuggetLocalizer>(() => new NuggetLocalizer(new i18nSettings(new WebConfigSettingService()), TextLocalizerForApp)); }
public DefaultRootServices() { // Use Lazy to delay the creation of objects to when a request is being processed. // When initializing the app thehi may throw "Request is not available in this context" from WebConfigService translationRepository = new Lazy<POTranslationRepository>(() => new POTranslationRepository(new i18nSettings(new WebConfigSettingService()))); urlLocalizer = new UrlLocalizer(); textLocalizer = new Lazy<TextLocalizer>(() => new TextLocalizer(new i18nSettings(new WebConfigSettingService()), TranslationRepositoryForApp)); earlyUrlLocalizer = new EarlyUrlLocalizer(urlLocalizer); nuggetLocalizer = new Lazy<NuggetLocalizer>(() => new NuggetLocalizer(new i18nSettings(new WebConfigSettingService()), TextLocalizerForApp)); }
public UrlUnlocalizationMiddleware(RequestDelegate next, IUrlLocalizer urlLocalizer, UrlUnlocalizationOptions options) { _next = next; _urlLocalizer = urlLocalizer; _options = options; }
public EarlyUrlLocalizer(IUrlLocalizer urlLocalizer) { m_urlLocalizer = urlLocalizer; }
public UrlLocalizationUrlHelper(IUrlHelper urlHelper, IUrlLocalizer urlLocalizer) : base(urlHelper.ActionContext) { _urlHelper = urlHelper; _urlLocalizer = urlLocalizer; }
public UrlLocalizationUrlHelperFactory(IUrlHelperFactory helperFactory, IUrlLocalizer urlLocalizer) { _helperFactory = helperFactory; _urlLocalizer = urlLocalizer; }