简体   繁体   English

网址中没有文件名和扩展名的起始页

[英]Start page without filename and extension in the URL

I am setting up a blank project in Visual Studio 2012 and have set my index.html as the start page. 我正在Visual Studio 2012中设置一个空白项目,并将index.html设置为起始页。 The problem I am having is that the URL now says "localhost:64237/app/index.html" as it is including the path to the index page. 我遇到的问题是该URL现在显示“ localhost:64237 / app / index.html”,因为它包括索引页面的路径。

I want to be able to type in "localhost:64237" and have it still access the index page, without showing me the rest of the path or the filename/extension in the URL. 我希望能够输入“ localhost:64237”并使它仍然访问索引页面,而无需向我显示路径的其余部分或URL中的文件名/扩展名。

Right-click the project and go to properties. 右键单击该项目,然后转到属性。 Select "web" on the left-hand side. 选择左侧的“网络”。 Under the "servers" section, you should be able to set it up with out "app". 在“服务器”部分下,您应该可以在不使用“应用程序”的情况下进行设置。 Once that's done, it should work like you want. 完成后,它应该可以按照您的意愿工作。 If not, look into IIS and Virtual Directories. 如果没有,请查看IIS和虚拟目录。

You can use routing. 您可以使用路由。

By using routing you can change this: 通过使用路由,您可以更改此设置:

http://www.mywebsite.com/Product/ProductDetails.aspx?id=1
http://www.mywebsite.com/ProductProductDetails.aspx?name=Apple

into this: 到这个:

http://www.mywebsite.com/Product/1
http://www.mywebsite.com/Product/Apple

or this: 或这个:

http://www.mywebsite.com/Apple

Find more info in google about ASP.NET Routing. 在Google中找到有关ASP.NET路由的更多信息。

good luck 祝好运

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

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