简体   繁体   English

为 .net 网络应用程序设置默认页面

[英]Set default page for .net web-application

I developed a .net web-application.我开发了一个 .net 网络应用程序。 If I start the development server in the browser like this:如果我像这样在浏览器中启动开发服务器:

http://localhost:<host number>/

I get to a directory listing.我进入目录列表。 I would rather get to a specific default page.我宁愿进入特定的默认页面。 In my case it´s located in the folder Applications/Default/ of the project and named default.aspx .就我而言,它位于项目的 Applications/Default/ 文件夹中,名为 default.aspx 。

I use .net 2.0 and VS 2005.我使用 .net 2.0 和 VS 2005。

To set the start up page in asp.net:在asp.net中设置启动页面:

  1. Right click in Solution explorer on the main folder name.在解决方案资源管理器中右键单击主文件夹名称。

  2. Select Property page.选择属性页。 Property page window will appear in front of you.属性页窗口将出现在您的面前。

  3. Select 'start option'.选择“开始选项”。 Then select 'Specific page' radio button.然后选择“特定页面”单选按钮。 Click of on the browser button which is right after the textbox of specific page.单击特定页面文本框后面的浏览器按钮。

  4. "Select page to start" Window appears in front of you. “选择要启动的页面”窗口出现在您的面前。 Select the page name which you want to set as start up web page.选择要设置为启动网页的页面名称。 Click “OK”.单击“确定”。

  5. You should be back to 'Property pages' window.您应该回到“属性页”窗口。 Click OK.单击确定。 Now Debug the page.现在调试页面。 You have set the start up page.您已经设置了启动页面。

In Visual Studio, right click on default.aspx and click 'Set as Start Page'.在 Visual Studio 中,右键单击 default.aspx,然后单击“设置为起始页”。 I'd recommend upgrading to .NET 4 if you're able to, but that would require updating your Visual Studio to 2010. 3.5 works with VS 2008.如果可以,我建议升级到 .NET 4,但这需要将 Visual Studio 更新到 2010。3.5 适用于 VS 2008。

If you are using the Visual Studio Development web server, you cannot specify a default page that will be served up when you navigate to "/".如果您使用的是 Visual Studio Development Web 服务器,则无法指定导航到“/”时将提供的默认页面。 It is hardwired to use "Default.aspx" ... this has been a standard page for a great long time and there should be little reason to deviate from it.使用“Default.aspx”是硬性的……很长一段时间以来,这一直是一个标准页面,应该没有什么理由偏离它。

What you can do is create a blank Default.aspx page and perform a Server.Transfer() on page load.您可以做的是创建一个空白的 Default.aspx 页面并在页面加载时执行 Server.Transfer()。

If you absolutely must specify a different start up page, and cannot create a Default.aspx page, then you must abandon the development server and opt to use IIS locally or use IIS Express, either should be able to debug applications, but may have features that require configuration.如果你必须指定一个不同的启动页面,并且不能创建一个 Default.aspx 页面,那么你必须放弃开发服务器并选择在本地使用 IIS 或使用 IIS Express,要么应该可以调试应用程序,但可能有功能需要配置的。

You need to set the startup page.您需要设置启动页面。

Select the aspx page that's to be the startup page.选择要作为启动页面的 aspx 页面。

Right click over it and select "Set as Start Page".右键单击它并选择“设置为起始页”。

Is your site hosted in your local IIS?您的站点是否托管在本地 IIS 中? In other words if you go to IIS on your machine is there a website or a virtual directory for your web application?换句话说,如果您在您的机器上访问 IIS,是否有您的 Web 应用程序的网站或虚拟目录? If so you may need to make sure that the default documents list contains an entry for default.aspx.如果是这样,您可能需要确保默认文档列表包含 default.aspx 条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM