views:

56

answers:

2

I need to either redirect user or show not authorized page according to usertype of the logged in user.

Here is some which would give you an idea.

public ActionResult Index() { if (Request.Cookies["isadmin"].Value != "true") return View("NotAuthorized","Index"); else return View(); }

Here I have created new view with NotAuthorized as view name and projectname.Models.NotAuthorized as strongly type view.

after building and running the project,it give me following error.

Parser Error Message: Could not load type 'System.Web.Mvc.ViewPage'.

Thanks in advance. Anil

A: 

Are you using the final version? Did you created the project using the VS template? Also, check your project references.

Rodrigo Guerreiro
Yes, I am using final version and not using any VS templates
ANIL MANE
A: 

YES :-)

I got it, here is solution.

if (Request.Cookies["isadmin"].Value != "true") //return Redirect(Request.UrlReferrer.ToString()); return RedirectToAction("NotAuthorized", "Users"); //return View("NotAuthorized"); else return View();

ANIL MANE