Is it necessary to have default.aspx in your project and as a starting page in ASP.Net

I have created an empty web project and added a web form named crud.aspx.
When I run the web app it says defualt.aspx was not found.
so I created an default.aspx.

Now the problem is that it opens defualt.aspx as a starting page however, I want to open crud.aspx as a starting page.

Right clicking the crud.aspx and setting it to starting page did not helped!

Also it would be super nice if I could get rid of default.aspx entirely.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Untested. See if this will work. In web.config:

<system.webServer>
    <defaultDocument enabled="true">
        <files>
            <clear/>
            <!--first preference-->
            <add value="default.aspx"/>
            <!--show second preference if first file is not found-->
            <add value="home.aspx"/>
        </files>
    </defaultDocument>
...

Try just adding the one page you want.

https://faragta.com/asp.net-web-forms/set-default-start-page-for-aspnet.html

Method 2

This is the code of my web.config, which fixed my problem provided by wazz (the accepted answer).

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>

 <!--what i added becuase of the stack overflow answer start01-->
  
  <system.webServer>
      <defaultDocument enabled="true">
          <files>
              <clear/>
              <!--first preference-->
              <add value="CRUD.aspx"/>
              <!--show second preference if first file is not found-->
              <add value="default.aspx"/>
          </files>
      </defaultDocument>
  </system.webServer>
  
 <!-- ended01-->
  
  <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1" />
    <authorization>
      <allow users="?" />
    </authorization>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=&quot;Web&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
</configuration>


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x