ASP.NET MVC - User access for directory

How can I add limited access to only 1 specific user has access to 1 specific directory and none else can access it than him? I've looked at the web.config thing but that wont work.

So basically what I'm trying to is:

Person creates user => new user => new directory (access ONLY for the new user and none else).

Thanks in advance.

Answers


The application I am currently working on uses the Authorize decoration in conjunction with the membership and role providers (both custom) to manage access to pages within my MVC site e.g.

[Authorize(Users="MyUsername")]
public ActionResult Banking()
{
   return View();
}

[Authorize(Roles="SysAdmin, BusinessOwner")]
public ActionResult Banking()
{
   return View();
}

I find this is extremely flexible as you can have public (no decoration) any logged in user [Authorize] or roles & users. Personally I would never build an app that authorized on Users - Roles is a much more extensible option (even if it does only contain one user at the moment) there are two main reasons I wouldn't do this - Users becomes unwieldy in a big app and secondly adding a user to the decoration requires a recompile/redeploy of the app whereas associating a user to a role in most situation is typically a database association that the app's business logic handles at runtime.

In your web.config you set up something similar to this to use the custom providers:

 <system.web>
<membership defaultProvider="MyMembership" userIsOnlineTimeWindow="30">
  <providers>
    <clear/>
    <add name="MyMembership" type="MyDAL.MyMembership, MyDAL"/>
  </providers>
</membership>
<roleManager defaultProvider="MyRole" enabled="true" cacheRolesInCookie="true">
  <providers>
    <clear/>
    <add name="MyRole" type="MyDAL.MyRole, MyDAL" />
  </providers>
</roleManager>

Then you create classes that inherit the providers:

using System.Web.Security;

namespace MyDAL
{
    class MyMembership : MembershipProvider//[ctrl + .] to create stubs
    {
        //Use Visual Studio to generate all the MembershipProvider stubs [ctrl + .]
    }
}

You will end up with a bunch of methods with throw new NotImplementedException() - there are heaps of these but it is not necessary to fill them all out - just complete the ones that are relevant to your application and leave the rest as is.


Need Your Help

Create TextView from template XML file

android layout textview

I have a template of simple TextView in a file simple_txt.xml

rgl package scatterplot labels

r graphics rgl

I seem to be having problems adding a title and axis labels in the rgl package. Here's a minimum working example:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.