public static IHtmlString MetaTagLanguage <T>(this HtmlHelper <T> html) { var currentLanguage = HttpUtility.HtmlAttributeEncode(Threading.Thread.CurrentThread.CurrentUICulture.ToString()); return(new MvcHtmlString(String.Format("<meta name=\"accept-language\" content=\"{0}\" >", currentLanguage))); }
internal static void Redirect(this HttpResponse t, string url, bool endResponse, bool permanent) { var @this = This.Get(t); if (url == null) { throw new ArgumentNullException("url"); } if (url.IndexOf('\n') >= 0) { throw new ArgumentException(EnvironmentEx2.GetResourceString("Cannot_redirect_to_newline")); } //if (_headersWritten) // throw new HttpException(EnvironmentEx.GetResourceString("Cannot_redirect_after_headers_sent")); var page = (@this._context.Handler as Page); if ((page != null) && page.IsCallback) { throw new ApplicationException(EnvironmentEx2.GetResourceString("Redirect_not_allowed_in_callback")); } //url = t.ApplyRedirectQueryStringIfRequired(url); //url = t.ApplyAppPathModifier(url); //url = t.ConvertToFullyQualifiedRedirectUrlIfRequired(url); //url = t.UrlEncodeRedirect(url); t.Clear(); if ((page != null) && page.IsPostBack && page.SmartNavigation && (@this.Request["__smartNavPostBack"] == "true")) { t.Write("<BODY><ASP_SMARTNAV_RDIR url=\""); t.Write(HttpUtility.HtmlEncode(url)); t.Write("\"></ASP_SMARTNAV_RDIR>"); t.Write("</BODY>"); } else { t.StatusCode = (permanent ? 301 : 302); t.RedirectLocation = url; url = (HttpContextEx.GetIsAbsoluteUrl(url) ? HttpUtility.HtmlAttributeEncode(url) : HttpUtility.HtmlAttributeEncode(HttpUtility.UrlEncode(url))); t.Write("<html><head><title>Object moved</title></head><body>\r\n"); t.Write("<h2>Object moved to <a href=\"" + url + "\">here</a>.</h2>\r\n"); t.Write("</body></html>\r\n"); } @this._isRequestBeingRedirected = true; //var redirecting = httpResponse.Redirecting; //if (redirecting != null) // redirecting(this, EventArgs.Empty); if (endResponse) { t.End(); } }