Default page is not working properly - c#

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

Related

Remove ASP.NET Version Information from error screen when Host is change

During the Pen Test, we received one vulnerability. Repro Steps was Change Host (let's say google.com) to different domain and then hit URL. Then following screen shown,
Here Version Information for dot net framework is showing. I weant through various atricals on internet and they are asking to used in web.config
This tag is already present in web.config and when we hit url without chaning Host it is showing error.aspx page but when we change Host it is showing attached page.In attached image Version Information is mentioned and I want to get rid of that.
Also on out testing envrionment,the version information is not shown with resource not found message. Is there any way to remove version information apart from customErrors tag. Please help me out. We are using IIS 10.
The tag you are already using in the web.config is probably the <customErrors> tag. and that's great for errors that can be caught at the .Net level.
But for errors that don't enter the .Net pipeline you will need to configure the IIS error page for the 404 error. This can be done via the <system.webServer><httpErrors> section of the web.config. For example to return the contents of my-iis-404-page.htm which you locate in the root directory of the website, you could use this:
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Auto">
<error statusCode="404" subStatusCode="" prefixLanguageFilePath="" path="my-iis-404-page.htm" responseMode="File" />
</httpErrors>
</system.webServer>
This configuration can also be done via the IIS gui. For more information about httpErrors aspect of IIS see https://learn.microsoft.com/en-us/iis/configuration/system.webserver/httperrors/
If you want to remove the X-Aspnet-Version HTTP header from each response from ASP.NET, add the following code to the web.config file.
<system.web>
<httpRuntime enableVersionHeader="false" />
</system.web>

<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.

Windows web app wrong start up page

I am creating a windows web app on visual studio. When launched, I need the web browser to start up with the login page but it doesnt, it starts up on a different page. Anyone know why? or how to remedy the problem?
Henks answer looks like what you want, but if you are using ASP.NET MVC? you could tag your controllers/methods with the [Authorize] attribute. This would redirect users that is not logged in to the login page (or any other page should you decide to override the defaults).
Go to your project's properties page (right-click on project, select properties).
Go to the "Web" tab
Change the "Start Action" to your login page.
I'm guessing that at the moment your setting is to open the current page.
You could modify your web.config file, in this way you could indicate the default page, something like this:
<system.webServer>
<defaultDocument>
<files>
<remove value="default.aspx"/>
<remove value="index.html"/>
<remove value="index.htm"/>
<add value="Login.aspx"/>
</files>
</defaultDocument>
</system.webServer>

Can't set default page on Azure Website

I published an Asp.Net web app on Azure website from Visual Studio and I can't manage setting a default page.
I have added this to web.config
<defaultDocument>
<files>
<clear />
<add value="Default.aspx" />
</files>
</defaultDocument>
I left only the "Default.aspx" on Azure control panel in Default Documents.
But when typing a hostname in address bar, I still get "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable".
How can I do it properly?
Thanks
When creating a website on azure I've chosen Asp.net Emply Website and the Default page (of my own) simply doesn't work there. Then I have created by an option of 'Quick Create' and it works great.
Go to App_Start\RouteConfig.cs and edit the rule properly. Or just delete them.

Categories