MS Identity and Access Tool MVC 4

2019-02-17 12:29发布

问题:

This VS 2012 extension is meant to allow me to add a local Development STS to my MVC application http://visualstudiogallery.msdn.microsoft.com/e21bf653-dfe1-4d81-b3d3-795cb104066e

I follow the very simple instructions e.g. Right Click the project name and select Identity and Access in the menu. Select your Identity Provider and the OK to apply the settings to your web.config.

I run my MVC 4 application and it redirects immediately to login.aspx

I'm guessing there are special instructions for MVC 4.

What are they?

Where do I find them?

EDIT

To be clear I have created a ASP.MVC 4 Internet application in visual studio 2012. Then I am using the Identity & Access Tool to add a local development STS to Test my application.

I am running the site on a local IIS Express

When I debug the application I am redirected to

localhost:11378/login.aspx?ReturnUrl=%2f

This occurs even if I remove forms authentication as suggested in advice already given.

回答1:

In my case I added this

<system.web>
...
<httpModules>
...
    <remove name="FormsAuthentication" />
</httpModules>
</system.web>

and this

<system.webServer>
...
   <modules>
   ...
      <remove name="FormsAuthentication" />
   </modules>
</system.webServer>

EDIT

The next problem you might get is this

A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier' or 'http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider' was not present on the provided ClaimsIdentity. To enable anti-forgery token support with claims-based authentication, please verify that the configured claims provider is providing both of these claims on the ClaimsIdentity instances it generates. If the configured claims provider instead uses a different claim type as a unique identifier, it can be configured by setting the static property AntiForgeryConfig.UniqueClaimTypeIdentifier.

add these 2 claims to the Development STS in the Identity and Access Tool

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier
http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider

and add this line to your Global.asax

AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

This article helped me



回答2:

Removing FormsAuthentication module worked for me.

 <httpModules>
    ...
    <remove name="FormsAuthentication" />
 </httpModules>


回答3:

I had a similar problem with my MVC4 application on local IIS Express.

It turned out that Windows Authentication was enabled for the project. Disabling Windows Authentication (in project properties pane -- press F4) fixed the problem.