Unable to load default aspx web page - asp.net

I have published my website in a directory called samp and i am currently trying to host it on IIS.
However i have numerous aspx pages. For example, members.aspx, default.aspx, authenticate.aspx, etc.
But i am not sure how do i make default.aspx to load when the user connects to localhost at port 80.
I am new at this, please help.

You can enable it through the Web.config file in your ASP.net website.
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="Default.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Note: This is especially important if you're debugging with IISExpress (i.e. inside Visual Studio 2015), where you don't heve the option to configure your default files directly (as in IIS - see freefaller's answer).

In IIS7 click on the website in question (under the "Sites" area of the left-hand tree), then find "Default Document" in the IIS group of icons. Double click the icon to go into the section, then click "Add..." in the Actions panel and then add "default.aspx" in the dialog.
You can then set the order of precedence by clicking on the new entry and moving it to the top of the list using the "Move Up" option in the Actions panel.
This will allocate the default document to the website in question - if you want it adding to ALL websites on IIS7, then do the same thing to the top level icon (the one under "Start Page")

Related

Correct path to publish to IIS

I've managed to deploy my website to test through Publish Web in VS2012 using the connection criteria below. This launches fine and works as expected but I need to keep clicking the publish button each time to get the page to launch.
However, rather than keep publishing each time, I'm trying to run it directly from IIS by opening IIS (inetmgr) select the site folder and browse. However, it tries to launch localhost/MyWebsite/ and not the full path localhost/MyWebsite/home.aspx so I get a blank page.
The project also has the home.aspx set as start page. Can anyone point out why I can't get this to run from IIS where it's already published? It's probably something obvious but I can't see it.
ON IIS, go to DEFAULT and add HOME.aspx, on the top of the list.
In IIS, you specifying that you want to browse that site which is "localhost/MyWebSite/" you could go into "Content View" and select "Home.aspx" and then select browse if you want the full path to that file for another solution.
Insted of setting default document from IIS set it from web.config . so that you no need to set default document every time .
Web.config
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="home.html" />
</files>
</defaultDocument>

How do I set the default page of my application in IIS7?

I deployed my web application to IIS7 and everything works just fine. However, instead of typing the url of my true starting page, I want it to automatically go to www.xxxxxx.com/views/root/default.aspx.
How do I do this?
Just go to web.config file and add following
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="Path of your Page" />
</files>
</defaultDocument>
</system.webServer>
On IIS Manager select your page in the Sites tree.
Double click on configuration editor.
Select system.webServer/defaultDocument in the drop-down.
Change the "default.aspx" to the name of your document.
Karan has posted the answer but that didn't work for me. So, I am posting what worked for me. If that didn't work then user can try this
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="myFile.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
On IIS Manager--> Http view--> double click on Default and write the name of your desired startup page, Thats it
For those who are newbie like me, Open IIS, expand your server name, choose sites, click on your website. On new install, it is Default web site. Click it. On the right side you have Default document option. Double click it. You will see default.htm, default.asp, index.htm etc.. to the extreme right click add. Enter the full name of your file(including extension) that you want to set it as default. click ok. Open cmd prompt as admin and reset iis. Remove all files from c:\inetpub\wwwroot folder like iisstart.html, index.html etc.
Note: This will automatically create web.config file in your c:\inetpub\wwwroot folder. I didnt have any web.config files in my inetpub or wwwroot folders. This automatically created one for me.
Next time when you enter http(s)://servername, it opens the default page you set.
If you want to do something like,User enter url "www.xxxxxx.com/views/root/" & default page is displayed then I guess you have to set the default/home/welcome page attribute in IIS. But if user just enters "www.xxxxxx.com" and you still want to forward to your url, then you have write a line of code in the default page to forward to your desired url. This default page should be in root directory of your application, so www.xxxxx.com will load www.xxxx.com/index.html which will redirect the user to your desired url
I was trying do the same of making a particular file my default page, instead of directory structure.
So in IIS server I had to go to Default Document, add the page that I want to make as default and at the same time, go to the Web.config file and update the defaultDocument header with "enabled=true". This worked for me. Hopefully it helps.

When publishing a web site, my default document name keeps getting removed from IIS

I have an ASP.NET web site project, which I'm publishing to IIS on my Win2k8 R2 server. It has a default page called login.aspx. I set that up on the published web site.
Trouble is, every time I publish a new version of the web site, the login.aspx entry gets erased from the "Default Document" settings of the web site in IIS. This is very annoying. How can I publish my web site from Visual Studio without wiping out the default page every time?
Try putting a defaultDocument in your site's web.config:
<system.webServer>
<!-- your other stuff -->
<defaultDocument enabled="true">
<files>
<clear/>
<add value="login.aspx"/>
</files>
</defaultDocument>
</system.webServer>
You are probably using "sub site", and the default document list of the root website is blank.
Try adding default document (even dummy) to the root website and see if it helps.
(Taken from here: http://forums.iis.net/t/1169880.aspx)
when the login.aspx is added to subsite. it's type 'local'. it gives this error.
you should add this page to the servere itself.
click the server and then choose the feature view--> iis--- default document then right click to add your "login.aspx" page.
now you should see this in default document of all your sub sites and it will not be erased in publish or server restart.
this is my personal exceperience
Omar kamel

Why isn't my IHttpHandler being called?

I'm trying to get a custom handler to work for a specific URL (or set of URLs) in ASP.NET 3.5.
The handler doesn't actually do anything significant yet - it just logs the request. I can post the code if anyone things it's relevant, but I really don't think it's being called at all. (In particular, for normal exceptions I get a custom error page and logging... here I'm just getting the vanilla IIS 404.)
Here's the relevant bit of the web.config file:
<system.web>
<httpHandlers>
<add verb="GET,POST" path="*.robot" validate="false"
type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
</httpHandlers>
</system.web>
(Obviously there's other stuff in that section too, but I don't think it's relevant.)
Locally, running under the dev server, it works fine. On my real box, I always get a 404. Everything under the web site directory itself is the same (replicated via svn). That includes the bin directory containing CSharpInDepth.dll, which I've verified contains CSharpInDepth.Wave.RobotHandler.
I try to fetch http://csharpindepth.com/foo.robot and just get a 404.
I've tried with and without the assembly name, specific URLs or wildcarded ones... nothing's working.
I'm sure I've just missed some simple flag somewhere in the IIS configuration, but I'm blowed if I can find it...
EDIT: It's IIS version 6. Attempting to add *.robot to the ISAPI filter now...
Well if the hosting box is IIS7 in integrated pipeline you need to add it into the other bit of the config:
<system.webmodules>
....
<modules>
<add name="RobotHandler" type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
</modules>
....
</system.webmodules>
If it's IIS6 then you'll need to map *.robots to the ASP.NET ISAPI DLL.
(For the non-Skeets you do this as follows)
Open up IIS admin.
Right click on
the Web site you want to configure
and select Properties form the
context menu. This will display the
Web Site Properties dialog.
Select
the Home Directory tab and click the
Configuration button. This will
display the Application
Configuration dialog box.
Click
Add.
Select the aspnet_isapi.dll
from the .NET framework directory,
the extension you want mapped and
either All Verbs, or just the ones
you want to map.
Click ok.
Jon,
You'll have to configure the IIS script mappings to pass *.robot to aspnet_isapi.dll.

Extensionless Page Requests

I have a customer of ours that sent out a publication referring to my site but they used the wrong address...they did not provide a page name...it looks like this:
mywebsite.org/Resources/toolkits/bridging
when it should have been
mywebsite.org/Resources/toolkits/bridging/default.aspx
Is there a way to tell ASP.NET to default to this default.aspx when it sees this kind of request or even better, have IIS 7 handle this easily?
This site is live so I would like to avoid having to introduce code if possible.
As per other suggestions, this should be done in the IIS configuration for your website using the IIS Admin tool.
There is however, another alternative - you can add a section in the web.config of your actual ASP.NET application, allowing you to override the IIS configuration right from your application:
<system.webServer>
<defaultDocument>
<files>
<clear />
<!-- Specify each of your files by order of preference here -->
<add value="Default.aspx" />
<add value="Index.aspx" />
<add value="MyOtherPage.aspx" />
</files>
</defaultDocument>
</system.webServer>
The caveat to this though is it may be a little obtuse when the IIS administrator can't figure out why the server configuration isn't working the way he's got it configured. It's not always right to do something just because you can.
Finally, just in case you don't have access to the IIS server or your IIS administrator has reasons for not adding Default.aspx to the default document list in the IIS configuration and for whatever reason, you don't wish to override the IIS configuration in your web.config file, then the quickest and simplest way is to simply create a file called default.asp in that directory containing:
<% Response.Redirect("default.aspx") %>
Default.asp is in the default document list on IIS. The code will automatically redirect the call to the correct page. The downside to this approach though is that there's a performance hit - every time someone calls default.asp - directly or otherwise, the redirect needs to happen which isn't free.
In the Documents tab of the web site properties in IIS you can specify default documents. If you are using .Net2.0 or later on that machine then Default.aspx should already be set....
Default.aspx is not, oddly enough, set as the default document in an IIS installation; In IIS 7, the setting is under "HTTP Features", called "Default Document". Add default.aspx to that list and you should be OK.
If not, you'll need to add a 404 handler that redirects when it sees that URL.

Resources