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
Related
In my project Index.aspx page is set as a default document.
I tried to debug is not firing the button click event on localhost:1992,but it is working perfectly on localhost:1992/Index.aspx.
ISSUE : project working in localhost:1992/Index.aspx not working localhost:1992
Kindly give the solution for this issue?
UPDATE
I've set Index.aspx page as the startup page
NOTE : Client side click is working. only server side click is the problem here.
Because you haven't specified a page as a startup page.
Right click on the page you want to be the start page and then click on the set as a start up page option.
You can do this by editing web.config file,
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.aspx"/>
</files>
</defaultDocument>
</system.webServer>
Use clear tag before add tag
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.
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 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.
I have asp.net web api project. I have deleted views folder and added index.html root level file to the solution.
Now when I visit the page http://localhost:59305/ it displays HTTP Error 403.14 - So html file is not opened.
How can I make the file to be opened first?
You have to configure the routing engine to ignore HTML files in the routing.
Use this in your Global.asax.cs:
RouteTable.Routes.IgnoreRoute("*.html");
Also try to set the default document in your web.config file. Add this:
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.html" />
</files>
</defaultDocument>
</system.webServer>