Recently I was working on a project that had a large amount of roles that were going to be utilized on many different controllers and even on individual controller actions. Originally it was given to me utilizing the standard out-of-the-box way of Authorizing with MVC 3.0: where we have to implement
1. Required Module to be enabled.
2. Required Privileges, Roles and Users to be available. And show/hide  menu, links and buttons etc.

i found a good reference here .

http://geekswithblogs.net/tyarmer/archive/2010/02/25/strongly-typed-roles-in-mvc-with-authorize-attribute.aspx

One thing I’ve noticed in AuthorizeAttribute there is no access to the RedirectToAction or RenderView methods. These methods are protected by the Controller class and therefore unaccessible under the filterContext.Controller.In my mind I can find several valid reasons why I would want to add an attribute and then possibly short circuit the action with another Redirect or Render. The only way I’ve found to get around this is to create my own base controller.

////////////////////// example /////////////////////////////////////

public class myAuthorizeAttribute : AuthorizeAttribute
{
public string Modules
{
get;
set;
}

public string Privileges
{
get;
set;
}

///——————————————————————————————–
///

/// Called when a process requests authorization.
///

///The Filter context, which encapsulates information for using . /// The parameter is null.
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);

if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
{
RedirectToAction(filterContext, “AccessDenied”, “User”);

}

// Developers have access to everything, so don’t bother loading permissions
if(MvcApplication.UserIsDeveloper)
{
return;
}

}

///——————————————————————————————–
///

/// Redirects to action.
///

///The filter context. ///The response code. ///Name of the action. public void RedirectToAction(ControllerContext filterContext, string actionName)
{
if(String.IsNullOrEmpty(actionName))
throw new ArgumentNullException(“actionName”);

RouteValueDictionary values = new RouteValueDictionary();
values.Add(“action”, actionName);

RedirectToAction(filterContext, values);
}

///——————————————————————————————–
///

/// Redirects to action.
///

///The filter context. ///The response code. ///Name of the action. ///Name of the controller. public void RedirectToAction(ControllerContext filterContext, string actionName, string controllerName)
{
if(String.IsNullOrEmpty(actionName))
throw new ArgumentNullException(“actionName”);

if(String.IsNullOrEmpty(controllerName))
throw new ArgumentNullException(“controllerName”);

RouteValueDictionary values = new RouteValueDictionary();
values.Add(“action”, actionName);
values.Add(“controller”, controllerName);

RedirectToAction(filterContext, values);
}

///——————————————————————————————–
///

/// Redirects to action.
///

///The filter context. ///The response code. ///The values. public void RedirectToAction(ControllerContext filterContext, RouteValueDictionary values)
{
VirtualPathData virtualPath = RouteTable.Routes.GetVirtualPath(filterContext.RequestContext, values);

string url = null;
if(virtualPath != null)
url = virtualPath.VirtualPath;

filterContext.HttpContext.Response.Redirect(url);
}

 
}

 

ref: http://forums.asp.net/t/1239842.aspx/1

http://www.telerik.com/community/forums/aspnet-mvc/grid/show-ellipsis-when-cell-content-is-larger-than-the-specified-width.aspx

That error usually is a result of the ASP.NET account not having permissions to a directory, possibly the windows temp directory. You cut off the error short, so I can’t see what the source file was, but look at the error on your end, see the directory the source file is in, give the ASP.NET account access to it, and you should be good.
This issue occurs if the user account does not have the List Folder Contents and Read permissions on the %windir%\Temp folder.

To resolve this issue, grant the user account the List Folder Contents and Read permissions on the %windir%\Temp folder.
Ref: http://forums.asp.net/t/985053.aspx/1

I’m using ASP.NET and I have a save button on webform. When that save button is clicked (ONCE) and I’m using IE8/IE7 the event handler is executed twice. If I use compatibility mode it works just fine. In FF everything works just fine.

We are using onserverclick on a button tag instead of using an asp.net button. The solution was to set the type of the button to “button”. Before no type was set and I think it was defaulting to submit.

Changed

<button id="button1" runat="server" onserverclick="button1_OnClick" /> 

To

<button id="button1" runat="server" type="button" onserverclick="button1_OnClick" />   its a silly mistake but beware of it.  ref:http://stackoverflow.com/questions/1349642/double-postback-using-ie8?s=c72971a9-65ce-4f68-a2bd-2d3f20e758d5 



Follow

Get every new post delivered to your Inbox.