How to Make HTML File Startup? - c#

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>

Related

<defaultDocument> in web.config adding last lash to URL

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

HTTP Error 403.14 ASP configuration

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.

Make static resource available in Azure Web Role

I need to access a web api in an Azure Web Role from a legacy Flash Application, and in order to do this Flash needs to be able to access a file called crossdomain.xml. I have added this file to the root of the application, but if I go to https://myapp.com/crossdomain.xml in the browser the file is downloaded. How can I get the xml to be shown in the browser?
Static xml files can be served by adding the following to web.config:
<handlers>
<add name="XMLHandler" type="System.Web.StaticFileHandler" path="*.xml" verb="GET" />
</handlers>
<staticContent>
<mimeMap fileExtension=".xml" mimeType="application/xml" />
</staticContent>

Make IIS 7.5 pass *.xml requests to asp.net

How do I configure IIS 7.5 to forward all *.xml file requests to asp.net engines so i can handle them in Global.asax and rewrite the path to a *.aspx file? Now IIS is expecting to find them directly on disk. I will use this do dynamically generate my sitemap.xml
You can force static files to go through the ASP.NET pipeline by editing your web.config:
<system.webServer>
<handlers>
<add name="XMLHandler" type="System.Web.StaticFileHandler" path="*.xml" verb="GET" />
</handlers>
</system.webServer>
HTTP Handlers and HTTP Modules Overview
How to: Register HTTP Handlers

Setting default at some port be some specific web service

currently I am running my web service from following path
http://localhost:16022/MachineService.asmx
and usage of some web method like
http://localhost:16022/MachineService.asmx?op=GetData1
I want to do it in following way
to run the web service from following path
http://localhost:16022/
and usage of some web method like
http://localhost:16022?op=GetData1
Is it possible to set it be the default ?
I am using VS2010.
Also possible to do so at the IIS7 itself ?
You can set the defaultDocument Element in your web.config file so you won't have to specify MachineService.asmx with each and every call.
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="MachineService.asmx" />
</files>
</defaultDocument>
</system.webServer>
Instead of manually modifying web.config you can configure the default document in Internet Information Services (IIS) Manager.

Categories