title: C# MVC Application_Error Redirect Page Not Html (It seems to be the string.)
body: <p>I created the page Application_Error in Global.asax</p>
  
  <p>I take  error.
  And I'm redirecting.</p>
  
  <p>Redirect Url = xxxxx.com/Error/E404</p>
  
  <p>But the page's source code shows.</p>
  
  <p><a href="https://i.stack.imgur.com/nQJTB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nQJTB.png" alt="enter image description here"></a></p>
  
  <p>ErrorController content;</p>
  
  <pre><code>public class ErrorController : Controller
  {
      // GET: Error
      public ActionResult E404()
      {
          var res = HttpContext.Response;
          return View();
      }
  }
  </code></pre>
  
  <p>Global.asax content;</p>
  
  <pre><code>protected void Application_Error()
      {
          var exception = Server.GetLastError();
          var httpException = exception as HttpException;
          var request = Request;
          Response.Clear();
          Server.ClearError();
          Response.TrySkipIisCustomErrors = true;
          var routeData = new RouteData();
          routeData.Values["controller"] = "Error";
          routeData.Values["action"] = "Index";
          routeData.Values["exception"] = exception;
          Response.StatusCode = 500;
  
          if (httpException != null)
          {
              Response.StatusCode = httpException.GetHttpCode();
  
              switch (Response.StatusCode)
              {
                  case 403:
                      routeData.Values["action"] = "E403";
                      break;
                  case 500:
                      routeData.Values["action"] = "E500";
                      break;
                  case 404:
                      routeData.Values["action"] = "E404";
                      break;
                  default:
                      routeData.Values["action"] = "General";
                      break;
              }
  
              // -- Save Log +
              string Url = request.Url.OriginalString;
              string Query = request.Url.Query;
              string ReferrerUrl = request.UrlReferrer == null ? null : request.UrlReferrer.ToString();
              string Browser = request.Browser.Browser;
              string UserAgent = request.UserAgent;
              string IpAddress = request.UserHostAddress;
              string iPv6Address = "";
              bool IsMobileDevice = request.Browser.IsMobileDevice;
  
              ActionLogger.Log_ApplicationError(Response.Status,
                  Response.StatusCode.ToString(),
                  Response.StatusDescription,
                  exception.HResult.ToString(),
                  exception.HelpLink,
                  exception.TargetSite.ToString(),
                  exception.Source,
                  exception.StackTrace,
                  Url,
                  Query,
                  DateTime.Now,
                  exception.Message,
                  IpAddress,
                  iPv6Address,
                  ReferrerUrl,
                  Browser,
                  UserAgent,
                  IsMobileDevice);
              // -- Save Log 
          }
          IController errorsController = new Controllers.ErrorController();
          var rc = new RequestContext(new HttpContextWrapper(Context), routeData);
          errorsController.Execute(rc);
      }
  
      protected void Application_Start()
      {
          AreaRegistration.RegisterAllAreas();
          WebApiConfig.Register(GlobalConfiguration.Configuration);
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
          RouteConfig.RegisterRoutes(RouteTable.Routes);
          BundleConfig.RegisterBundles(BundleTable.Bundles);
          GlobalConfiguration.Configuration.EnsureInitialized();
  
          RegisterViewEngine(ViewEngines.Engines);
  </code></pre>
  
  <p>ThemeApplicationBuild.RegisterApplication(this);</p>
  
  <p>}</p>
  
  <p>...</p>