Hi people am trying to hide the edit page in MVC3 C# so when a user trys to enter "Edit" in the browser some form of page comes up informaing the user this is not allowed.
If you require more information please ask
Thank You
I suggest setting up redirects in your config file. Add the following to system.web in your web.config file and update the redirect path to whatever you want to redirect to..
<customErrors mode="On" defaultRedirect="Error">
<error statusCode="302" redirect="Error/PageNotFound" />
<error statusCode="404" redirect="Error/PageNotFound" />
<error statusCode="403" redirect="Error/AuthorizationError" />
</customErrors>
It doesn't sound like you actually want something that specifically handles returning errors for an edit page. It sounds like you want a global way of processing any uncaught errors. Specifically, how to handle 404 errors, AKA errors that happen when a user accesses a page that doesn't exist.
See http://community.codesmithtools.com/CodeSmith_Community/b/tdupont/archive/2011/03/01/error-handling-and-customerrors-and-mvc3-oh-my.aspx for ideas, it includes information on how to handle 404 errors in MVC3.
You shouldn't be getting an error specifically telling you your View doesn't exist unless you created an action with no corresponding View. Given that there is no edit page, if you do have an edit action I would delete it.
You can put the [Authorize] attribute on the controller action method.
[Authorize(Roles = "Admin, Super User")]
public ActionResult Edit()
{
return View();
}
code
[Authorize("9EE075C8-30EB-4F53-B648-7B794F6FC2C2")] ...code
Scorpion-Prince 2012-04-05 20:50
code
return View("Error");code
from the controller action - Scorpion-Prince 2012-04-05 21:01
hide
in the question? what are you trying to achiev - Rafay 2012-04-05 20:45