Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

NotFound Page in Asp.net Core

$
0
0

Hi,

i want design 404 page in my project and i have use culture root ,

my startup

 app.Use(async (context, next) =>
            {
                await next();
                if (context.Response.StatusCode == 404)
                {
                    context.Request.Path = "fa/error_404";
                    await next();
                }
            });

 app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();

                endpoints.MapControllerRoute(
                name: "areas",
                pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{culture=fa}/{controller=Home}/{action=Index}/{id?}");



            });
 [Route("/error_404")]
        [Route("{culture}/error_404")]
        public async Task<IActionResult> AboutUs()
        {           
            return View();
        }

my default url is /fa

but when i search a not exsits url for example  /fa/Jfejsfd    its not got error_404 action and return not found





Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>