I get this error while trying to initiate a project in ASP. I have already added
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
To the Web.config but I still get this error. Also, I have tried initiating the IIS Express by opening appcmd.exe but this did not fix it either. None of the solutions I have found worked for me so far.
Any ideas?.
Step 1. Open IIS
Step 2. Go to the WebSite you are facing issue with.
Step 3. Click on Default Document Button, you will find it on the right side tab in IIS.
Step 4. You can see a list of default documents, but your default page (aspx file) is not mentioned here and that is causing the issue.
Add your file here. (For example: Index.aspx)
You can also add the following entry into the web.config:
<system.webServer>
<defaultDocument>
<files>
<add value="Index.aspx" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
</system.webServer>
Hope it helps.
Related
I tried to launch a C# web project from Visual Studio 2017 emulator and it doesn't work:
HTTP Error 403.14 - Forbidden
I'm using IIS and I'm not in wwwroot.
I already tried to activate in IIS but it's not what I want.
Any advice?
403.14 - Forbidden "The Web server is configured to not list the contents of this directory." is related to the directory your application is running in.
This problem might occur as you don't have neither Directory Browsing feature enabled nor you have configured a default document.
<system.webServer>
<defaultDocument>
<files>
<add value="your index file here" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
</system.webServer>
or
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
This page shows you the way how to configure one of the two features mentioned.
I have the strangest error. I am uploading my .NET 4.0 application on a new server and want to set the default document in the web.config file using the code below.
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="http://domain/folder/home.aspx" />
</files>
</defaultDocument>
<system.webServer>
The problem is when the page is loaded it goes to http://domain/folder/home.aspx/ with a last lash added which causes the header and menu not to load. If I delete the last lash after the URL everything loads fine.
My question is how to I set the default page without the last lash adding to the URL.
I tried setting the default document from the control panel on my server but it will not allow me to route to a sub folder
Sorry if this has been asked before, but I couldn't find a solution to this problem.
My route is defined as a/{param1}/{param2}/{param3}/{param4}/{param5}.
Everything works when the parameters are simply words, but when any of the parameter look like someword%2bsomeotherword, everything breaks and the route isn't matched. If I remove the %2b, then the route is resolved.
This is the first route registered, so I don't think it's finding a better route first.
Sorry if this is answered somewhere, but I have gone through a bunch of SO answers and other links. Routes in MVC have always eluded me.
Thank you for any help.
The issue is IIS here, not the solution itself / code.
Option 1 :
Mess with config to bypass request validation / allowDoubleEscaping (Asp.Net)
You need to be aware for certain risk/vulnabilirities described here:
https://stackoverflow.com/a/53621095/4798459
Asp.net :
use web.config directly in solution add this: Credit: https://stackoverflow.com/a/6026291/4798459
<system.web>
<httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
<pages validateRequest="false" />
</system.web>
.netcore :
Since this issues is related to IIS, not your solution. You need to handle a web.config
Create a new web.config on the root of your project.
Right click, properties, set "Copy to Output Directory" to "Copy Always"
When you publish a .net core app, a "basic web.config" file is created. (For iis)
You need to copy the content of the "basic web.config".
You can find the auto-generated web.config file:
Where your app is already published (local server?)
You can also publish your api temporarly to a random path on your PC, see details here https://docs.devexpress.com/OfficeFileAPI/401445/dotnet-core-support/publish-net-core-application)
The web.config should like so, i added the tag with a a commentt
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<!-- XML node <security> is added to allow allowDoubleEscaping and add support for + paremeter in a route. Risk:https://stackoverflow.com/a/53621095/4798459 -->
<security>
<requestFiltering allowDoubleEscaping="true"></requestFiltering>
</security>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments="[.\SolutionName.Namespace.dll]" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Make sure that the step 2 is done before publishing your app otherwise it wont work.
Not tested with iisexpress
Option 2
Change pramater type in the api. Intead of being on the route, use a queryString instead
Option 3
Custom solution for request filtetring /routing, which i don't have any example, and seems a bit "over the top".
Option 4, to avoid:
Use an other solution for encoding / decoding special caracter (I have not tried)
https://stackoverflow.com/a/55637235/4798459
I updated my ASP.NET Core project from RC1 to 1.0 RTM (with preview2 tooling), everything went fine. I can debug in Visual Studio without problems. Next I would like to upload the site on a Windows Server 2008 R2 and IIS 7.5. I installed the necessary Windows Hosting tools and created the web application in the IIS. The problem is, that after I tried to open the page, it returned a 404 error. As I see in the task manager, my application is running, but stops in listening mode.
In the log file I only see these entries:
Hosting environment: Production
Content root path: C:\inetpub\wwwroot\MySite
Now listening on: http://localhost:20706
Application started. Press Ctrl+C to shut down.
It seems like there is some problem with the IIS integration. My web.config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="..\..\approot\MySite\MySite.exe" arguments="" forwardWindowsAuthToken="true" stdoutLogEnabled="true" />
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
I tried some workarounds from GitHub, which affected the Startup.cs file's Configure method without any success.
Any ideas?
FYI.. This web.config file was missing in the app folder.
This file should be at: C:\wwwwroot\myapp\
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\XXX.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
Don't forget to replace XXX.exe with the correct name of your Web API exe name.
Ok, I had multiple problems, but the two main reasons why my site didn't work:
I cannot start the code from two separate places. I originally put the wwwroot content under the wwwroot folder (not so suprising), and the rest to the approot. Now everything should be in the same folder.
My release versions didn't want to work. I must use the contents of the debug folder. I don't know why.
And now, everything is ok.
please click on .cshtml file in Views folder and set build action=Content in right bottom panel in Visual Studio. My problem has been solved
I am getting a 401.2 error on the default document in VS2013 (and IIS). Here are the steps I'm taking:
In VS2013, right click choose "New Project"
Choose "ASP.NET Web Application", click OK
Choose "Empty" project, Check "Web Forms" at the bottom and click OK
Right click on the project and choose "Add | Web Form" - named
Default.aspx with "Authentication Succeeded" as the page content
Right click on the project and choose "Add | Web Form" - named
Login.aspx
Add a "Login" as the page content
Assign an "Authentication" event handler that sets "e.Authenticated
= true"
Update the web.config as listed below
Press F5
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Forms">
<forms loginUrl="Login.aspx" />
</authentication>
</system.web>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="default.aspx" />
</files>
</defaultDocument>
<security>
<authorization>
<remove users="*"/>
<add accessType="Deny" users="?" />
<add accessType="Allow" users="*"/>
</authorization>
</security>
</system.webServer>
</configuration>
The behavior that I'm seeing is that http://localhost:12345/Default.aspx behaves correctly (always). In other words, when I first go to Default.aspx, it redirects me to the Login.aspx page. Once I've authenticated, I can see the Default.aspx page. If I logout and try to go to the Default.aspx page again it redirects me to login first.
However, when I got the / URL instead (no Default.aspx) I get a 401.2 error (even if I've authenticated 1st)?
The Default.aspx page is listed as a default document, and if I remove the "Deny" line from the Web.Config - then the default document behaves as expected. But when Deny ? is listed in the web config, suddenly the default document stops working and I have to go to /Default.aspx in order to avoid a 401.2 error.
Any suggests as to why this would behave like this?
I see no errors about any of this in the event log. I see the same behavior when using IISExpress (in VS by pressing F5) or with IIS when going to the public URL directly through a browser.
I hesitate to offer this as an answer as I don't understand exactly why it worked for me. However it is too long for a comment and it might help you.
I found that adding the following to the System.Webserver section solved this problem:
<modules>
<remove name="FormsAuthentication"/>
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
</modules>
The key seems to be to remove the managedHandler Precondition from the FormsAuthentication module. As I understand it this is only supposed to optimize serving of static content. So I do not at this point know why it would have this effect. I stumbled on this trying to establish if FormsAuthentication module needed to be registered in the System.Webserver section.