简体   繁体   中英

Using IdentityServer, when running CreateUser access is denied for .json file

I have just set up IdentityServer for a new .NET Framework 4.7.2 application.

When I register a user using the standard form it manages to create the user in the database however I get the following error appear.

Server Error in '/' Application.
Access to the path 'C:\Program Files (x86)\IIS Express\20190124154304_636839413844068496.json' is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\IIS Express\20190124154304_636839413844068496.json' is denied. 

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. 

To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error: 


Line 154:            {
Line 155:                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
Line 156:                var result = await UserManager.CreateAsync(user, model.Password);
Line 157:                if (result.Succeeded)
Line 158:                {

Source File: C:\Repositories\Viper\Viper.Web\Controllers\AccountController.cs    Line: 156 

Stack Trace: 


[UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\IIS Express\20190124154304_636839413844068496.json' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +12856161
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +776
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +60
   

Couldn't post all Stacktrace, but can upload image if needed. I am completely stuck on why it is trying to create this file.

Any advice on this would be much appreciated. Thanks

I think it's AppPool execution issue so as shown in the error the current Identity of AppPool not authorized to access this json file.

Please try to change the WebApp's AppPool identity by going to the AppPool > choose Advanced settings > Identity > choose a user with admin privileges and enter his password.

Then from windows cmd (Run As Admin):

iisreset

And try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM