asp.net-mvc-2

Finding authorization framework to be used on a ASP.NET MVC project

岁酱吖の 提交于 2019-12-03 16:42:46
I have a asp.net mvc project and persistent is handled by repositories . Form authentication is used. Now I need implement authorization . For example , I need to ensure a manager user can only open his/her taskes and assign workers to the taskes. A worker will only see taskes that have been assigned to him/her. A super-moderator can edit everything. Is there any ready to use framework that allow me to define permissions ? I am in the process of evaluating Ayende Rhino Security . Where can I get more examples codes ? What is your opinion on Rhino Security ? My project use Linq to SQL and has

POST Json without model and Ajax

自作多情 提交于 2019-12-03 16:33:27
For now, I just want to use HTTP POST to send json to asp.net mvc2 controller. Since the JSON is actually a list of JSON objects, and each of them has different fields & length, so it hard for me to make up a input model. So I want to know is there a way for me to post JSON without model/ajax to a controller in ASP.NET MVC2? Building on @Brian's answer, we have done exactly this. Keep in mind this is Jquery 1.4.2 This is broken out a bit and could be simplified, but it is using callbacks instead of full on posts. It was initially used for filtering results real time and reloading the first

Problem creating persistent authentication cookie: ASP.NET MVC

只愿长相守 提交于 2019-12-03 16:32:07
问题 OK, here's my code to create an authentication cookie: // get user's role List<UserType> roles = rc.rolesRepository.GetUserRoles(rc.userLoginRepository.GetUserID(userName)); List<string> rolesList = (from r in roles select r.ToString()).ToList(); string[] rolesArr = rolesList.ToArray(); // create encryption cookie FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1, userName, DateTime.Now, DateTime.Now.AddDays(90), createPersistentCookie, String.Join(";",rolesArr) //user's

ASP.NET MVC 2 - How to ignore an entire directory using IgnoreRoute?

℡╲_俬逩灬. 提交于 2019-12-03 16:29:49
问题 I've tried the following two methods to try and ignore my "Assets" folder, but I keep coming up with errors. Can anyone tell me exactly how the Ignore Regex is supposed to look? routes.IgnoreRoute("/Assets/") routes.IgnoreRoute("{*assets}", New With {.assets = "\/Assets\/(.*)"}) 回答1: Try routes.RouteExistingFiles = false routes.IgnoreRoute("Assets/{*pathInfo}") 回答2: routes.IgnoreRoute("Ignore/"); will prevent the standard The controller for path '/Crap/Home' was not found or does not

ASP.NET MVC - Current Action from controller code?

血红的双手。 提交于 2019-12-03 16:23:35
问题 This is very similar to another recent question: How can I return the current action in an ASP.NET MVC view? However, I want to get the name of the current action from within controller code. So within the code of a function that's being called by an Action, I want to get a string of the name of the current Action. Is this possible? 回答1: You can access the route data from within your controller class like this: var actionName = ControllerContext.RouteData.GetRequiredString("action"); Or, if

Passing parameters to MVC Ajax.ActionLink

狂风中的少年 提交于 2019-12-03 15:57:29
How can I send the value of the TextBox as a parameter of the ActionLink? I need to use the Html.TextBoxFor <%= Html.TextBoxFor(m => m.SomeField)%> <%= Ajax.ActionLink("Link Text", "MyAction", "MyController", new { foo = "I need here the content of the textBox, I mean the 'SomeField' value"}, new AjaxOptions{ UpdateTargetId = "updateTargetId"} )%> The Contoller/Actions looks like this: public class MyController{ public ActionResult MyAction(string foo) { /* return your content */ } } Using MVC 2.0 How can I send the value of the TextBox as a parameter of the ActionLink? The semantically

advice on architecting asp.net mvc applications

一个人想着一个人 提交于 2019-12-03 15:56:03
I've been using ASP.net MVC for about two years now and I'm still learning the best way to structure an application. I wanted to throw out these ideas that I've gathered and see if they are "acceptable" ways in the community to design MVC applications. Here is my basic layout: DataAccess Project - Contains all repository classes, LINQ-to-SQL data contexts, Filters, and custom business objects for non-MS SQL db repositories (that LINQ-to-SQL doesn't create). The repositories typically only have basic CRUD for the object they're managing. Service Project - Contains service classes that perform

Custom IIdentity and IPrincipal using FormsAuthenticationTicket cookie in MVC2

*爱你&永不变心* 提交于 2019-12-03 15:48:29
I am currently trying to implement some custom security in an ASP.NET MVC2 web application. I am trying to do something really simple as my code below shows but for some reason if I use the [Authorize(Roles="Admins")] attribute on one of my controller actions, check the Context.User.IsInRole("Admins") or Page.User.IsInRole("Admins") it is always false. It is also weird that the User.Identity.Name is also blank. See my code below, I am using a FormsAuthenticationTicket within a cookie which I then use in the Application_AuthenticateRequest event handle within my Gloabl.asax to set the Context

is a background worker in a controller async?

邮差的信 提交于 2019-12-03 15:48:14
Inside an asp.net mvc 2 controller, I have the following code: using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += new DoWorkEventHandler(blah); worker.RunWorkerAsync(var); } My question is: is this code async, meaning it launches a new thread and the controller returns the view while 'blah' is executing in parallel? If not, how would I achieve these results? In MVC 2 there is a new feature called the AsyncController which is the correct way to do async calls in MVC. Your controller should inherit from AsyncController rather than controller. Then you your primary action

Custom errors override in ASP.NET MVC area

大兔子大兔子 提交于 2019-12-03 15:47:53
I would like to have custom error pages unique to an MVC area. Unfortunately, it appears that the Web.config override system doesn't take the MVC folder structure into account. If I want to override an area called "mobile", I have to create a root project folder (in with Views and Controllers) named "mobile" and put the Web.config in there with the new customErrors element. Is there some better way to do this so that I don't have to create a root folder for any overrides? I've been looking for exactly the same thing. One slight change that I do is to use a location element within the main web