Guest User

Guest User

  • Tech Writer
  • 3
  • 99

This page isn’t working right nowfof.extranet.nationalgrid.com redirts

Nov 23 2020 11:29 AM
Hi All,
 
Hope all are doing Good!!.
 
I am going to make a Custom Error page in MVC application,already my application is hosted in Azure portal.
 
I try to build a code in VS and working in Local good but Hosted in Azure is getting error like below
 
This page isn’t working
fof.extranet.nationalgrid.com redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
 
Please help me to reslove the issue,
 
I am creating on error controller like below code
 
and i am creating respective Index View and Http404 view. and http500
  1. public class ErrorController : Controller  
  2. {  
  3. //  
  4. // GET: /Error/  
  5. [HandleError]  
  6. public ActionResult Index()  
  7. {  
  8. return View();  
  9. }  
  10. public ActionResult http404()  
  11. {  
  12. Response.StatusCode = 404;  
  13. Response.TrySkipIisCustomErrors = true;  
  14.   
  15. return View();  
  16. }  
  17. public ActionResult http500()  
  18. {  
  19. Response.StatusCode = 500;  
  20. Response.TrySkipIisCustomErrors = true;  
  21.   
  22. return View();  
  23. }  
This is the Http404View...
  1. @{  
  2. ViewBag.Title = "http404";  
  3. }  
  4. <h2>http404</h2>  
  5. <h1> Displaying Custom error page</h1>  
and adding Web.Config file like below
  1. <customErrors mode="On" defaultRedirect="~/Error/">  
  2. <error statusCode="404" redirect="~/Error/http404"/>  
  3. <error statusCode="500" redirect="~/Error/http500"/>  
  4. </customErrors>  
and Adding Global.Asax file like below code
  1. protected void Application_Error(object sender,EventArgs e)  
  2. {  
  3. Exception exce = Server.GetLastError();  
  4. Response.Clear();  
  5. HttpException httpexception = exce as HttpException;  
  6. RouteData route = new RouteData();  
  7. var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);  
  8. route.Values.Add("controller""Error");  
  9. if(httpexception!=null)  
  10. {  
  11. switch(httpexception.GetHashCode())  
  12. {  
  13. case 404:  
  14. route.Values.Add("action""http404");  
  15. break;  
  16. case 500:  
  17. route.Values.Add("action""http500");  
  18. break;  
  19. }  
  20. Server.ClearError();  
  21. Response.TrySkipIisCustomErrors = true;  
  22. IController cntrl = new ErrorController();  
  23. Response.Redirect("~/Error/http404");  
  24. cntrl.Execute(new RequestContext(new HttpContextWrapper(Context), route));  
  25. }  
and i am commented below line in Filterconfig.cs
  1. public static void RegisterGlobalFilters(GlobalFilterCollection filters)  
  2. {  
  3. // filters.Add(new HandleErrorAttribute());  
  4. }  
Could you please help me and give any Suggissions,how to resolve this issue it is in critical now. please.....
Regards,

Answers (1)