I've an Admin area and I want only Admins to enter the area. I considered adding the Authorized attribute to every controller in the Admin area. Isn't there an elegant solution or is this feature not there in the framework itself?
EDIT:
I should to have mentioned this before. I'm using a custom AuthorizedAttribute derived from AuthorizeAttribute.
I used ModalPopup Control on this link, [URL]How should I write the code that to close pop up by click the area outside the pop up panel?I use AjaxControlToolkit-Framework3.5SP1
I am using ASP.NET MVC 3 and am trying to do something that should be really straight forward...
My application uses Forms authentication and that is working perfectly for controllers/actions. For example if I decorate either a controller or an action with the attribute below only members of the administrators group can view them:
[Authorize(Roles="Administrators")]
However I have a folder under the default Scripts folder called Admin. I only want members of the Administrators group to be able to access scripts within this directory so I created a new web.config in the directory with the following inside:
[code]....
However no matter whether a user is a member of the Administrators group or not they receive a 302 Found message and are then redirected to the login page.
If I change the web.config to allow user="*" then it works. It also works if I add an allow users="Username" for a specific user I am testing with.
When a user attempts to directly visit the url admin.aspx, and they are not an admin, they are redirected to the login page. However, the user then attempts to visit ViewWeek.aspx, it indicates that they are still logged in. Why does this ASP.NET authorization boot the user to the login screen, yet keep the user logged in? I'd rather it just direct the user to the default URL specified in the forms tag.
Our team has recently implemented a role permission based authorization so that we can have granular control. This is similar to what Rockford Lhotka suggests herehttp://www.lhotka.net/weblog/PermissionbasedAuthorizationVsRolebasedAuthorization.aspx I have also read about the Claims based authorization which to me looks very similar to what we have. Can some one put in simple terms what the advantages of claims based authorization are.
My routes work in the Global.asax, but I created an Area called Dashboard and while it works with the default route, it doesn't when I implement the T4MVC route.
Here's my Dashboard Area Registration class:
[Code]....
If I view this in a browser with the above settings, any Html.ActionLinks render as empty strings, no routing at all.Here's the rendered HTML from the route.
On a pager I use on my MVC site I create the page links as follows:
[Code]....
On a MVC 2 web site I have an area named CMS.For example, on "cms/article/list" the pager works fine.However, on my root views, for example in "article/index" the page 1 link become:[URL]On my Global.Asax I have the following:
[Code]....
I have been going around with this and I can't find a way to solve this problem.
Sure this is something obvious, but I can't see it.I have an area in my project, UserAdministration. Whenever I call anything in the area I get a 404 error.The AreaRegistration class contains:
[Code]....
The AdminController contains a method for Index.RouteDebug shows the route is to the correct controller (Admin) and action (Index).
I have moved AccountController to area named 'Backend', but when I adding [Authorize] attribute to any action and then come to this website, it redirects me to error page:
I have the area Blog with controllers (Post and Blog) i want that when the user acess my site without one area, it should redirect him to the Blog area inthe blog controller and in the index action if i use:
I have a problem, that is in my asp.net page I am having a master page there are many derived pages are there. in the master page I kept login control and validation and signin done in the master page itself, also I am having a create user page, if I execute create user page, unable to login from this page. because create user text box validating as well in the same page if I click create user button its validating login. how to avoid this? a button & text box & validation should be respective area only.
I have a site (ex. test.com) which I am using MVC. I have created areas for my site, where each area represents a state. What I would like to do is specify some place in the web.config to when I deploy, I set a value and then the default route when I go to test.com would auto route to: test.com/california or test.com/oregon based on that value.
I've got a piece of code that I want to run one time when my website is first loaded.It is basically a static initialization of another module.Is there some event I can hook into that runs when the site is first served to a client?It doesn't even need to be per session, just on first load to any client.
i have been visiting alot of websites , and they have my area name which i did not told him(ofcourse). So just curious whats the trick behind this if i want to implant that how does can i achieve that?
was wondering how do I make it so when a user goes to a page its only displayed if he is logged in and secure, but if he is not logged in he is redirected to the login page?
Iam using forms authentication in asp.net Application,i want to make pages accessible depending upon roles defined in database. for eg there are three rolesdefined in database salary admin, manager, Clerk. i want a page salary.aspx can be accessed only by salary admin and not any other roles.
I'm writting an application where I want to execute some code before a controller is invoked, even before the controller is created. I would like to somehow hook into the request processing as early as possible after the request is parsed and the RouteData is available. I've tried to hook in by handling the BeginRequest event but at this point there is no RouteData. Is there another place I can look for the area when BeginRequest delivered or is there another place in the request processing pipe that I can hook in to find the area before my controller is invoked.
I have a tab, under that there is a textarea. Now I want to clear the value of the textarea when I am going to another tab.I need javascript function because I made the property of tabcontainer autopostback= false.
I have an several controllers where I want every ActionResult to return the same viewdata. In this case, I know I will always need basic product and employee information.
Right now I've been doing something like this:
[code]....
This is just pseudo-code so forgive any obvious errors, is there a better way to be doing this? I thought of having my controller inherit a class that pretty much does the same thing you see here, but I didn't see any great advantages to that. It feels like what I'm doing is wrong and unmaintable, what's the best way to go about this?
public static MenuItem MainMenu(UrlHelper url) { Menu.DefaultIconDirectory = url.Content("~/Public/Images/"); Menu.DefaultDisabledClass = "disabled"; Menu.DefaultSelectedClass = "current"; return Menu.Begin( Menu.Items("", Menu.Action<HomeController>(p => p.Index(), "Home") ), Menu.Items("", Menu.Secure<HomeController>(p => p.About(), "About") ), Menu.Items("", Menu.Action<RegulationController>(p => p.Index(null), "Compliance") )/* This is in the Compliance area */ ).SetListClass("menu"); }
But I am also using MvcContib Areas and in the code above the final menu item is in an 'Area' called 'Compliance'.
(There are two other areas in the Mvc application and the first in the list of registered areas is called 'Legislation')
What happens is the following:
When a page is rendered (I am using the standard WebFormsViewEngine) the Urls are all rendered using the 'Legislation' area!!?
E.g. http://localhost:1337/Legislation/Home or http://localhost:1337/Legislation/Home/About
and finally http://localhost:1337/Legislation/Regulation
The first two links should not pick up the 'Legislation' area. The last menu item should be in the 'Compliance' area.
How do I prevent the erroneous Area (Legislation) being rendered on the first two links?
How do I get the MenuBuilder markup in the Site.Master to accept an 'area' attribute or get it picked up automatically from the Controller for each link?
Ok so the story is my users need a multi-select dropdownlist, which doesn't exist in ASP.NET, so the simple solution I'm going with is I'm using listboxes with multiselect on and I start them off at size 1, and onmouseover I change the size to say 10, onmouseout sets it back to one. Simple enough and the users don't know the difference.
Now, my issue comes from the fact that since I have any number of controls on my web app, I've set these listboxes to higher z-index numbers than the other controls, which creates a problem: on my listboxes closer to the bottom of the page the list expands below and not above, and part of the listbox goes under the bottom of the page but since onmouseout resets the size of the listbox I can't scroll the page down.
Does anybody know what I need to set to make it expand up instead of down?
edit Also, some may ask "why don't you just rearrange the listbox to a higher position in the page," the reason this isn't a viable option is I have well over 40 controls on the page and it they're grouped cohesively, I didn't just randomly place them where they are.(ie. investment info in one section, account in another, suitability in another)