Skip to content
Loading
error handing in dot net core   index view
  1. @ViewBag.Message  
// middleware setup
  1. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)  
  2.        {  
  3.            if (env.IsDevelopment())  
  4.            {  
  5.                app.UseDeveloperExceptionPage();  
  6.            }  
  7.            else  
  8.            {  
  9.                app.UseExceptionHandler("/Error");  
  10.                
  11.            }  
  12.            app.UseStatusCodePagesWithRedirects("/Error/{0}");  
  13.            app.UseStaticFiles();  
  14.            app.UseMvc(configureRoutes =>  
  15.            {  
  16.                configureRoutes.MapRoute("default""{Controller=Home}/{Action=Index}/{id?}");  
  17.   
  18.            });  
  19.   
  20.        }  
 
+1
  • Jay Krishna Reddy
    Hi, you can use the status codes that can accept the IActionResult method in.Net core, Please go through the below link to know the status codes to handle the exceptions in return type 
     
    https://developer.mozilla.org/en-US/docs/Web/HTTP/Status 
    +1