I have very strange problem. I'm using IIS 7.0 Integrated mode for my application. (pool is ASP 2.0 integrated)
It's working fine when i type www.xyz.com/MainPage.aspx. But when i used simple www.xyz.com then its not working.
I always get this error
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /intranet/default.aspx
I have mapped default document to MainPage.aspx still its not working... I don't have default.aspx page in root. only Mainpage.aspx and I can't change it...
my web.config looks like this (only part of it :):
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="MainPage.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Check you web.config and make sure the default.aspx is not listed as one the default pages. Recycle the app pool and restart IIS.
<system.webServer>
<defaultDocument>
<files>
<remove value="Default.htm"/>
<remove value="Default.asp"/>
<remove value="index.htm"/>
<remove value="index.html"/>
<remove value="default.aspx"/>
<remove value="iisstart.htm"/>
<add value="MainPage.aspx"/>
</files>
</defaultDocument>
You need to add MainPage.aspx as default page through IIS's document facility. You may also add a default document with IIS7 web.config.
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="MainPage.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
I think this setting is locked in IIS7 on applicationHost.config level. You have to change the root config gile or use IIS Administration API do complete this task.
Related
I got a website published to server under 192.168.2.3.
I want access to the login page without including the full URL, I want it to be done by just entering URL 192.168.2.3, then after processing it become 192.168.2.3/login.aspx.
The problem I currently encounter is that it always goes to default.aspx.
I had tried to add some code at web.config and it just came out as the error shown below.
<configuration>
<appSettings />
<connectionStrings>
<add name="CompWebConnectionString" connectionString="Data Source=TDSPWEBSVR\SQLSERVER2008;Initial Catalog=CompWeb;User ID=sa;Password=tdspp#ssw0rd" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<defaultDocument>
<files>
<clear />
<add value="TechnicianProgram/login.aspx" />
</files>
</defaultDocument>
On your site in IIS one feature is Default Document. Check what has been set there. You may want to remove everything but the required login page path which will enable IIS to return the login page if the request URL does not specify a specific path.
This setting will update your web.config file with the values something like below-
<location path="folder1">
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="login.aspx"/>
</files>
</defaultDocument>
</system.webServer>
</location>
This seems pretty simple, but for the life of me I can't figure it out.
Using ASP.NET Classic (ie non-MVC), say I have a website www.foo.com that has an /api folder, and in that folder is the file api.aspx (i.e. you hit www.foo.com/api/api.aspx)
How can I set things up (either via Web.config rewrite or via MapPageRoute() in Global.asax.cs) so that www.foo.com/api
hits /api/api.aspx not /api/Default.aspx
doesn't show api.aspx in the browser's URL box (I just want to see either www.foo.com/api or www.foo.com/api/)
I would have thought that this would work:
routes.MapPageRoute("ApiRoute","api","~/Api/Api.aspx");
but it doesn't... I still hit /api/Default.aspx
EDIT:
I also want to support /abc/abc.aspx and /thing/thing.aspx, mostly so when I have these pages open in the IDE they're not all named "Default.aspx" and I can't quickly see which page is which.
I've created a small demo project. Each folder I want to set a specific default document I add a web.config file.
project structure
Each web.config file defines a default file for it's folder.
web.config in folderA
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear/>
<add value="a.aspx"/>
</files>
</defaultDocument>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Accordingly for folderB
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear/>
<add value="b.aspx"/>
</files>
</defaultDocument>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
ATTENTION
When I did some tests in my development webServer it did not work. But
when I published my project to my local IIS instance it did work out
all right.
local IIS deployment
I want to be able to view the code behind files from the browser while in the development stage. To do this, I would disable the default handler of .cs files, HttpForbiddenHandler in the web.config.
Since I am using IIS 7, I first placed the <remove> element in <system.webServer> section like this:
<system.webServer>
<handlers>
<remove path="*.cs" verb="*"/>
<add verb="*" path="*.cspx" type="HandlersAndModules.CspxHandler, HandlersAndModules" name="CspxHandler"/>
</handlers>
</system.webServer>
and I got the error when I run the application:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
This is because the element in in <system.webServer> section does not recognize attributes verb and path.
Then I tried moving <remove> element to <system.web> section like this:
<system.web>
<httpHandlers>
<remove path="*.cs" verb="*"/>
</httpHandlers>
</system.web>
and I got the error when I run the application:
HTTP Error 500.23 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
How do I disable the default handler HttpForbiddenHandler that prevents .cs files from being viewed from the browser?
You need 2 things:
First, to get .cs files served as content, you need to add this:
<system.web>
<httpHandlers>
<remove path="*.cs" verb="*"/>
<add verb="GET" path="*.cs" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>
Second, to avoid HTTP Error 500.23, add this as a workaround:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
500.23 error indicates that not all your handlers and modules are specified in system.webServer section. If you're in position to specify them there, then do that instead of the workaround. The workaround just buys you time till you're able to migrate your settings.
How to set startup page for a specific folder?
First you have to add web.config file in folder and in your web.config add this rule
<defaultDocument enabled="true">
<files>
<clear/>
<add value="index.aspx"/>
</files>
</defaultDocument>
<modules runAllManagedModulesForAllRequests="true"/>
ok i found solution.
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear/>
<add value="Pages/Default.aspx"/>
</files>
</defaultDocument>
<modules runAllManagedModulesForAllRequests="true"/>
Just name it default.aspx and that's it.
UPDATE:
May be you check if default.aspx in defined in IIS as default document or not.
Check links below. It'll guide you to check if settings of IIS are OK or not.
http://www.iis.net/learn/web-hosting/web-server-for-shared-hosting/default-documents
http://www.iis.net/configreference/system.webserver/defaultdocument
Setting Default WebPage in IIS 7.5
Hope it helps
I'm training my web.config to recognize what the best default file is. According to my host it's supposed to look like in the listing below.
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings/>
<system.web>
<defaultDocument>
<files>
<clear />
<add value="Defalut.aspx" />
</files>
</defaultDocument>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime/>
<pages controlRenderingCompatibilityVersion="4.0"/>
<machineKey/>
<customErrors defaultRedirect="Error.aspx" mode="On"/>
</system.web>
</configuration>
The problem is that VS2012 (Express) marks it blue and claims the error in the subject. First i thought that i could upload it as it is and by brute force make the server to like the file but it then got angry and spat out the following
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
As i read the error message it says that: "The configuration section 'defaultDocument' cannot be read because it is missing a section declaration."
I've done my homework and found the article below but due to the limitation in my situation (e.g. i need to manually upload the web.config file and i can't run any scripts on the server of my hosting company), it was to no avail.
How do i kill this little problem?
"Defalut.aspx" is a definite yellow flag.
SUGGESTION:
Just create a new dummy project with MSVS2012 (I don't have a copy handy, so I can't help you at the moment)
Cut and paste the auto-generated "web.config" into your project and verify that it works.
If it doesn't, make ONLY those MINIMAL changes needed to get a clean compile/execute.
Save a backup of your working web.config
Try adding your "defaultDocument" section and see what happens.
If it still doesn't work, please cut/paste:
a) the exact section (as I presume you did above)
b) the exact error message
ALSO:
Q: It now fails in BOTH your MSVS2012 (running locally) AND your target web server, correct?
Q: Are you sure the target web server is ASP.Net 4.0 capable?
You config looks correct but the error occurs because it cannot find the file that is mean to be the default document for all your website folders
So please replace "Defalut.aspx" with he correct spelling of the file in the below xml
<defaultDocument>
<files>
<clear />
<add value=*"Defalut.aspx"* />
</files>
</defaultDocument>
Late to the party, I know, but for anybody still with a similar problem, I don't believe this has anything to do with the spelling of the default page name (that will probably just give a 404 when it's accessed).
The real issue is that the defaultDocument section should actually be under system.webServer, not system.web. See defaultDocument Element for more info.
So your sample config file should look something like:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings/>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime/>
<pages controlRenderingCompatibilityVersion="4.0"/>
<machineKey/>
<customErrors defaultRedirect="Error.aspx" mode="On"/>
</system.web>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="Defalut.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>