So I am very new to web development and have a .NET MVC site that I have been working on. Unfortunately, Visual Studio removes most of the work in running a simple site in debug. I am trying to learn about more of what gets generated when you build and fire up a website through Visual Studio so I can have more control over deploying additional sites.
PROBLEM
So in IIS I created a new site and defined the Site name, and pointed the physical path to the Web directory of my project (contains the web.config).
In Visual Studio, under the Web project properties changed
Start Action -> "Don't open a page, wait for request"
Servers -> "Use specific IIS web server" and specify the URL of the site name I defined in IIS (i.e. local.acme.com).
Cleaned solution, rebuilt and tried navigating to http://local.acme.com. After getting past some original permissions issues (dir requiring permissions for IIS_USERs), it tries to automatically direct me to a view that doesn't exist:
http://local.acme.com/Account/LogOn?ReturnUrl=%2f
NOTE I created the project as a "EMPTY" MVC 2 Web application, so no default .NET MVC account view should exist.
Any thoughts
Check your web.config . does it contain any entry for membership and authentication
An entry, something like this in <system.web>
<authentication mode="Forms">
<forms loginUrl="Account/LogOn" />
</authentication>
Remove the <authentication> element from Web.config.
Related
I created an App in VS 2017. It has a SQL Database (Entity Framework connected) and other MVC components. in the local IIS it works without any trouble.
Assume the Project is in folder (of local machine) : MVCPrj
I have a website and it has a particular folder, in which there is a Web Forms project and that runs in the site without any trouble as well.
Assume the Project is in Folder : BaseFolderInMySite\WebFormsPrj
The following works without any trouble
http://www.mySite/WebFormsPrj/default.aspx
For testing purposes, I need to create a separate folder inside BaseFolderInMySite and I want to place the MVC project inside it.
I created that folder and published the app. I can see the files properly placed in the directory. But that site gives an error page. The old one works.
If I summarize:
The Webforms app in BaseFolderInMySite\WebFormsPrj works for http://www.mySite/WebFormsPrj/default.aspx
The MVC app in BaseFolderInMySite\MVCPrj doesn't works for http://www.mySite/MVCPrj
Here is the error message
enter image description here
Since it is saying the web,config file has the issue, I checked it. It is the line with
<authentication mode="None" />
I googled, checked thoroughly in SO and tried to get it fixed by various means and failed.
I removed the <system.web> thinking that it conflicts with the main app, which is running.
Changed the mode to Windows, Forms, ... no luck.
My question is how do I fix this.
Before everyone reads this, I just want to say that i know that there are related threads out there, but I have either tried them or do not understand. With that being said here goes nothing...
I am trying to get a MVC Web App running in my IIS. Unfortunately, I am absolutely stuck on this error:
HTTP Error 500.19 - Internal Server Error
The Request page cannot be accessed becasue the related configuration data for
the page is invalid.
Module: IIS Web Core
Notification: BeginRequest
Handler: Not yet determined
Error Code: 0x80070005
Config Error: Cannot read configuration file due to insufficient permissions
Config File: \foo\web.config
Request URL: http://localhost/WEBAPP
Logon Method: Not yet determined
Logon User: Not yet determined
Config Source
-1:
0:
I am not quite sure what else to do. I have also tried giving read permission to the web.config file and that did not seem to work.
If anyone has any information or would be able to help me work through this it would be much appreciated. Thanks!
In my case I needed to install the IIS URL rewrite module 2.0 because it is being used in the web.config and this was the first time running site on new machine.
On this MSDN blog: Troubleshooting HTTP 500.19 Errors in IIS 7 in scenario 8 for error code 0x80070005 (E_ACCESSDENIED - General access denied error) it says:
Grant Read permission to the IIS_IUSRS group ...
.... the worker process identity (and/or the IIS_IUSRS group) needs at least Read access to the directory so that it can check for a web.config file in that directory.
Please follow these step
Go to Control Panel
Go to Programs and Features
Turn Window Feature on or off
Go to Internet Information Service node
Follow World wide web Services
Then Please Check Application Development Feature
Then Please check all Node Specially Asp or Application Framework Like Asp.net 3.5 or ASP.NET 4.5 whatever you have
I fixed this by restarting VS.
I had opened a config file in another instance of VS and apparently sth went nuts...
Goto Windows Features on or Off . Enable All Features under Application Development Features and Refresh the IIS. Its Working
I was trying to run a .net core 3.1 site from IIS 10 on windows 10 pro box, and got this error. Did the following to resolve it.
First turn on the following iis feature on.
Then follow the link below.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1#install-the-net-core-hosting-bundle
Install the .net core hosting bundle.
The direct link is
https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-aspnetcore-3.1.2-windows-hosting-bundle-installer
I have installed the .net core sdk and run time as well. But this did not resolve the issue.
What made the difference is the .net core hosting bundle.
I had a sub folder named web.config renaming this folder resolved the issue
For completeness, the answer to Asp.Net Core tag in web.config causes failure may also be the solution to the problem here. If the .NET Core Windows Server Hosting bundle is not installed then IIS cannot recognize the aspNetCore section in web.config. https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1#install-the-net-core-hosting-bundle claims to be a direct download to the current version.
I tried all solution above. My issue is resolved after reinstalling hosting bundle.
I installed hosting bundle before in IIS Manager installation.
I think this is caused error. Don't know why, but, the reinstallation works.
My issue is that I accidentally installed another site as the default site instead of the IIS default (by opening another project.) I had to remove the default site and repoint it to the default location C:\inetpub\wwwroot using my domain login as the user to bypass with then just reopened my project that I was trying to run (the one showing this error) and it was all honky dorry
I was accessing the project from inside a Virtual Machine - sharing the project folder from the host OS (Windows 10). After trying many of the solutions, and even ensuring the permissions for the IIS_IUSRS are given, still I could solve this.
Eventually, I copied this folder from the host, onto a path on the guest OS, and now I can properly run that same ASP.NET project without ado. But, I did also go ahead and give the IIS_IUSRS group full control over this new dir as well... maybe that's not really necessary in this case? I'm lazy to test that ATM.
Delete .vs/Config folder => work for me
In my case I had .Net core SDK 3.1.403 was installed. So I installed the corresponding .Net Core Windows Server Hosting which is .NET core 3.1.9 - Windows Server Hosting.
I had this problem to run restful service on IIS in Windows 10 and Windows Server 2019, finally after a lot of researches I solved the problem. After performing the following steps, the problem will most likely be solved.
Go to the "Windows Features" and active full features IIS ("Internet Information Services" or "Web Server") and active .Net Features
Locate the source at "C:\inetpub\wwwroot"
Open IIS
Click "Edit Permissions" on your web after go to the security tab and give full
access to the IIS_IUSRS
Go to the "Application Pool" next right click on your app pool after click on "Advanced settings" and change "Identity" to "LocalSystem"
Go to the "Application Pool" next right click on your app pool after click on "Basic settings" and change ".NET CLR Version" to "No Managed Code"
If you want to set the service to a specific port, first set it to port 80 and then edit it and set your port
Well now if the problem is still not solved then install the following software on the system :
URL Rewrite 2
WebPlatform
DotNetCore.2.0.8 Windows-Hosting
Dotnet-hosting 5
Dotnet-runtime 5
MicrosoftServiceFabricSDK 5
NET.Framework 4.8
and finally restart the system.
If Folder getting from other, and host file is already generated on ProjectName\.vs\config folder, then it conflicts with a new one and gets this error.
So delete host file from ProjectName\.vs\config and restart project once again. It was worked for me
In my case, Server had lower version framework than your application. installed latest version framework and it fixed this issue.
In the Edit Application Pool window, set the .NET CLR version to No Managed Code
I had this error with Visual Studion 2019, my project was NopCommerce 4.30 which is an ASP.Net Core 3.1 project. I added page "gouden-munten-buitenland" to be the starting page and I only got the error when going to that page. Turned out that Visual Studio generated an invalid applicationHost.config :
<applicationPools>
....
<add name="gouden-munten-buitenland AppPool" autoStart="true" />
<add name="gouden-munten-buitenland AppPool 2" autoStart="true" /> <!-- WRONG -->
<add name="Nop.Web AppPool" managedRuntimeVersion="" />
<applicationPoolDefaults managedRuntimeVersion="v4.0">
<processModel loadUserProfile="true" setProfileEnvironment="false" />
</applicationPoolDefaults>
</applicationPools>
and
<sites>
....
<site name="Nop.Web" id="2">
...
<application path="/gouden-munten-buitenland/gouden-munten-buitenland" applicationPool="gouden-munten-buitenland AppPool">
<virtualDirectory path="/" physicalPath="C:\Usr\Stephan\Wrk\Kevelam\kNop.430\Presentation\Nop.Web" />
</application>
<application path="/gouden-munten-buitenland" applicationPool="gouden-munten-buitenland AppPool 2">
<virtualDirectory path="/" physicalPath="C:\Usr\Stephan\Wrk\Kevelam\kNop.430\Presentation\Nop.Web" />
</application> <!-- WRONG -->
....
</site>
...
</sites>
I removed the nodes identified as 'WRONG' and then it worked.
If your error is using a site in asp.net core, install the ASP.NET Core Windows hosting bundle.
Click on the link below and select your .net core version
In the following page find the link "Hosting bundle" (ctrl+f may help) and install it.
Worked a treat for me!
https://dotnet.microsoft.com/en-us/download/dotnet
One reason, for which I face this issue was a web.config file in Images folder (on abnormal location) and IIS was trying to allow the read rights according to incorrect settings in the web.config file.
Therefore make sure your build is correctly deployed without any abnormal files specially the configs one on invalid locaiton.
I am using IIS Express to deploy MVC4 application. This website runs perfectly on same computer. But in Lan it gives me error 401.
<authentication mode="Forms">
<forms loginUrl="~/" slidingExpiration="true" timeout="20">
</forms>
</authentication>
In home controller
[HttpPost]
[AllowAnonymous]
public ActionResult Index(LoginModel model, string returnUrl)
{
}
I am starting IIS server from command prompt in Administrator mode. IIS responds to the request with error 401.
Any clue?
I realize this is an older post but I had the same error on IIS 8.5. Hopefully this can help another experiencing the same issue (I didn't see my issue outlined in other questions with a similar title).
Everything seemed set up correctly with the Application Pool Identity, but I continued to receive the error. After much digging, there is a setting for the anonymous user to use the credentials of the application pool identity or a specific user. For whatever reason, mine was defaulted to a specific user. Altering the setting to the App Pool Identity fixed the issue for me.
IIS Manager → Sites → Website
Double click "Authentication"
Select Anonymous Authentication
From the Actions panel, select Edit
Select Application pool Identity and click ok
Hopefully this saves someone else some time!
If you're using IIS 7 do something like this:
Select your site.
Click on error pages.
Edit feature settings.
Select detailed errors.
Make sure that you enabled anonymous authentication on iis like this:
In case anyone is still looking for this, this solved the problem for us:
To whoever this may help, this saved my life...
IIS 7 was difficult for figuring out why i was getting the 401 - Unauthorized: Access is denied due to invalid credentials... until i did this...
Open IIS and select the website that is causing the 401
Open the "Authentication" property under the "IIS" header
Click the "Windows Authentication" item and click "Providers"
For me the issue was that Negotiate was above NTLM. I assume that there was some kind of handshake going on behind the scenes, but i was never really authenticated. I moved the NTLM to the top most spot, and BAM that fixed it.
Here is the link where this was found.
I had this issue on IIS 10. This is how I fixed it.
Open IIS
Select The Site
Open Authentication
Edit Anonymous Authentication
Select Application Pool Identity
I realize its an old question, but this came up in my searches. Had a similar issue for an MVC application recently built, deployed for the first time, and Authentication mechanism wasn't completely hashed out.
It wasn't an IIS setting in my case, it was a Controller that was not [AllowAnonymous] decorated. I was using a Render.Action/Html.Action in a Layout.cshtml and the User was unauthenticated. So the Layout tried to load an Authenticated Action in an UnAuthenticated context.
Once I updated the action to AllowAnonymous, the problem went away, and this is what led me to it.
Hope this helps someone.
I faced this error when I created an empty project with the MVC folders and then deployed the application to the server. My issue was that I didn't define the authentication in Web.config, so all I had to do was add this line to a system.web tag.
<system.web>
<authentication mode="None"/>
</system.web>
I faced similar issue.
The folder was shared and Authenticated Users permission was provided, which solved my issue.
I had a similar issue today. For some reason, my GET request was fine, but PUT request was failing for my WCF WebHttp Service
Adding the following to the Web.config solved the issue
<system.web>
<authentication mode="Forms" />
</system.web>
i faced the same issue under IIS 8.5. A working solution for me was changing the IIS to display detailled errors. See answer from sna2stha. But i think it is not a good idea to forward detailed error messages to browsers in production enviroments.
I added/changed the existingResponse attribute in the httpErrors-Section, so the IIS not handled any extisting Asp.net Response:
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
This works for me.
In my case, what made it work was changing the Anonymous User identity from Specific user (IUSR) to Application Pool Identity. Weird enought because other sites are using the specific user IUSR and work fine.
As so many answers have demonstrated, the error might be caused by a variety of reasons. In my case it was connected to authorization rules: they were added much later after the application was deployed. This feature of IIS is turned on as a Windows component (World Wide Web Services->Security->URL Authorization).
This particular section inside web.config was to blame:
<system.webServer>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Deny" users="?" />
<add accessType="Deny" users="user1,user2" />
<add accessType="Allow" users="*" />
</authorization>
</security>
</system.webServer>
Thus the record for users="?" blocked access to a path with anonymous authentication too since it inherited the rules by default. However, in IIS you can go to a particular folder/file that should be accessed anonymously and choose Authorization Rules:
Here it's possible to overwrite the rules locally by removing the old one and optionally adding the allowed rule instead to make it more explicit:
Right click on the main directory where the project files are located.
Properties-> Security-> Edit-> Add-> type IIS_IUSRS and click on "Check Names" button.
The result will look like ComputerUsername\IIS_IUSRS
For example: DESKTOP-M0R6PVF\IIS_IUSRS
and then click on "Ok" button.
I had a slightly different problem. The credential problem was for the underlying user running the application, not the user trying to login. One way to test this is to go to IIS Management -> Sites -> Your Site -> Basic Settings -> Test Settings.
I had a permissions issue to a website and just couldn't get Windows authentication to work. It was a folder permissions rather than ASP.NET configuration issue in the end and once the Everyone user was granted permissions it started working.
You can press F4 on the web project to get the "Project Properties" window.
Then make sure Anonymous Authentication is Enabled in the "Development Server" section:
In my case,
My application is developed in MVC and my home controller class was decorated with [Authorize] which was causing this issue.
So I've removed it because my application don't require any authentication.
Sorry for the newbie question, but I can't seem to figure this out. I have been basically following this example from Microsoft on how to create a web site with logins:
http://msdn.microsoft.com/en-us/library/879kf95c.aspx
I did deviate from the example some in that I went ahead and created roles (Admin, user). I created a folder called "Admin" and inside there is a web page. I configured the Security wizard to Deny access to that page for Anonymous, User, and All Users. When I run the page in Visual Studio it will not let me see the page unless I log in, but once I log in I can see the page. When I publish the web site and try it from another computer (or even the local one for that matter) it will let me see the page without logging in.
I am certain I have no idea how to correctly publish the database. When I first published the page the login that I created in the security wizard was not valid, so I copied the aspnetdb into the App_Config folder in my application directory and it would now let me log in, but it does not seem to be holding the access rules that I have set. I'm pretty certain that I am not publishing correctly but I've been unable to figure out what the correct way to move the settings over is when publishing.
I found the answer apparently it is considered a bug is VS (maybe maybe not)...
but the answer can be found here
http://www.tino.nl/index.php/2008/06/17/publishing-an-aspnet-site-that-uses-membership-components/
The access rules are NOT in your database but in the web.config. Perhaps your web.config is not correctly deployed with the app.
You can edit the Deny/Access rules in the web.config using the location element ( http://msdn.microsoft.com/en-us/library/b6x6shw7(v=vs.100).aspx ) for the folders or individual pages:
<configuration>
<location path="Logon.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
</configuration>
So you need to make sure the rules at your local machine are also in the web.config on the server.This is not done automatically.
Recently we migrated our development environment from VS2008 to VS2010 (Ultimate).
For one solution (for now all C#, .NET Framework 3.5 and ASP.NET 2.0) which contains 6 projects VS auto-upgraded it without any problems.
The solution projects are:
ASP.NET website
VS2010 Web Deployment project for above site
Web Services Application
VS2010 Web Deployment project for above WSA
A class library.
Another class library.
However, when we build we have 1 error:
Could not load file or assembly 'ClassLibrary1BLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))
After research I finally tracked this to one entry in the ASP.NET website config:
If I build with this line the problem occurs:
<identity impersonate="true" userName="DOMAIN\user" password="password"/>
However, if I comment out and build with the following line (without the supplied credentials) the solution builds fine AND then amend the web.config back to the above (with the credentials) the site runs fine - the credentials only cause a problem for the build.
<identity impersonate="true"/>
Now here is the strangest issue - the Web Services Application builds fine with the supplied credentials - the build error ONLY occurs for the ASP.NET website. This all holds true whether the projects are built individually or the solution rebuilt.
Any pointers how I can successfully build with the supplied credentials will be greatly appreciated.
Check the permissions of the impersonation user.
After just setting the flag to false, <identity impersonate="false"/>, it also came to life for me.
However, once setting it back to true, it built fine, but when I loaded the site, I got:
The current identity (XN-DTDEV\Fusion)
does not have write access to
'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary
ASP.NET Files'.
Now this machine is on a domain, and that user is local, which should have administrative privileges. When I checked back, it didn't. It looks like there is a policy re-setting the local administrators each reboot.
I realize there's already an accepted answer, but for anyone else coming to this page via a search on the error code....
Review the permissions of the user that you're trying to impersonate.
In my situation, I was only getting the error on my development machine, rather then on our staging or deployment servers. (For a while I got around this by removing the 'identity' node from config in my dev environment and just adding the line in post-build so it wasn't a problem anyone other than me..
In my environment we have a specific user that all our web apps impersonate when running. I had created the user account, but hadn't explicitly set its account permissions. When I added the user as an Adminstrator on my dev machine, this problem went away completely. (Not ideal, I know, but it "works for me", and has minimal harm since that user account is locked down on our 'real' servers anyways..)
after changing permissions on "Temporary ASP.NET Files" you need to delete its contents and allow the new files to inherit the new security permissions
If any of the solutions mentioned before didn't work, and you're using impersonation.
The answer is to give permission for the user that you're impersonating access to the following folders :
C:\Windows\Microsoft.NET\Framework[v4.0.30319 or the version that you're using]\Temporary ASP.NET Files
Your site directory.
also you might need to create folder as the following :
C:\Windows\Microsoft.NET\Framework\[v4.0.30319 or the version that you're using]\Temporary ASP.NET Files\[Application-Name-Goes-Here]
But try the previous first, it worked for me.
Those two changes for granting the impersonated user permission to be able to save the temp data, and pull the dll files, and any needed files from the directories
Thanks for the reply mattdwen - unfortunately your suggestion never worked (the 'Temporary ASP.NET Files' folder permissions were correct) but did provide the hint that lead to me (HACK) resolving the problem. After reading your answer I tried the following which led me in a different direction:
(1) I successfully rebuilt the solution 3 times using <impersonate="true"/>, <identity impersonate="false"/> and <identity impersonate="true" userName="DOMAIN\different-user" password="password"/> (here "different-user" is a local admin).
(2) I then amended the web.config back to the original <identity impersonate="true" userName="DOMAIN\user" password="password"/> and ONLY rebuilt the ASP.NET website project - success.
This has led me to conclude (strongly hinted at by the original error message) that VS when rebuilding the solution is unable (for as yet unknown reason) to build one of the Class Libraries or its dependencies with <identity impersonate="true" userName="DOMAIN\user" password="password"/> in the ASP.NET website project.
The Class Library in question has a number of references to 3rd party components, Office interops, etc. which for now would be too time consuming to attempt to eliminate one by one and discover the real underlying reason.
Therefore, I have temporarily implemented the hack (cringe) to add the original user to local admins.