TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rohit Singh
NA
749
88.2k
How to create custom error page for 401 in MVC
Aug 16 2017 4:09 AM
Hi. I've been facing this issue so long and tried almost everything but couldn't get what I want.
I want to display an custom error page for code 401 , if the user is not authorized to view any particular part of my webApplication. Kindly solve my problem.
What I have tried:
This is my web.config file:
<customErrors mode="On">
<error statusCode="404" redirect="~/Error/NotFound"/>
<error statusCode="401" redirect="~/Home/SecureMethod"/>
This is My Controller:
[HandleError]
public class HomeController : Controller
{
[Authorize]
public ActionResult SecureMethod()
{
return View();
}
[AllowAnonymous]
public ActionResult NonSecureMethod()
{
return View();
}
I have also enabled the Windows Authentication and Anonymous Authentication on IIS Server
Reply
Answers (
2
)
Error Message in confirmedEmail
how to use rich text in we application without third party