CMS 的 URL 路由
我正在开发一个 CMS,它将用户内容存储在数据库表中,如下所示:
---------------------------------------- PageId | PageTitle(Unique) | Content ---------------------------------------- 1 | PageOne | ... 2 | PageTwo | ... 3 | PageThree | ... 4 | PageFour | ...
现在我在根目录中有一个 aspx 页面“SitePageFactory.aspx”,当查询字符串传递给它时,该页面提供动态内容,假设 /SitePageFactory.aspx?pgid=1被传递,然后它为 PageOne 提供内容。
上面的概念运行良好。
现在我想更进一步,向该应用程序添加动态路由并将 /SitePageFactory.aspx?pgid=1 修改为 /PageOne.aspx 但无法在根级别执行此操作。
注意:目前我能够执行像 /SitePageFactory/PageOne.aspx 这样的路由,但我希望结果位于根级别。
谢谢。
I am developing a CMS that stores user content in a database table like this:
---------------------------------------- PageId | PageTitle(Unique) | Content ---------------------------------------- 1 | PageOne | ... 2 | PageTwo | ... 3 | PageThree | ... 4 | PageFour | ...
Now I have an aspx page "SitePageFactory.aspx" at root that serves dynamic content when a querystring is passed to it, suppose /SitePageFactory.aspx?pgid=1 is passed then it serves the content for PageOne.
The concept above is working fine.
Now I want to put a step further by adding dynamic routes to this application and modify /SitePageFactory.aspx?pgid=1 to /PageOne.aspx but unable to do it at root level.
NOTE: Currently I am able to perform routing like /SitePageFactory/PageOne.aspx but I want the results at the root level.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 ASP.NET 路由来完成此任务。
路由让您可以将 www.mysite.com/pages/pageone 之类的 url 映射到 aspx 页面。 url 中的不同部分可以映射到您可以在 aspx 中访问的路由参数。
<一href="http://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CCYQFjAA&url=http://m sdn.microsoft.com/en-us/library/ie/cc668201.aspx&ei=vrEjT6jcPIKk-gbZla2-CA&usg=AFQjCNFjNNOphHEfp1qCeFbwB1PWbh4--A" rel="nofollow">这里是路由的 MSDN 文档。
您可以添加以下路由:
这会将 url www.yourdomain/ 映射到页面控制器 ViewPage 方法。
You can use ASP.NET Routing to accomplish this.
Routing let's you map an url like: www.mysite.com/pages/pageone to an aspx page. The different parts in your url can be mapped to route parameters that you can access in your aspx.
Here is the MSDN documentation for routing.
You can add the folowing route:
This will map the url www.yourdomain/ to the Page controllers ViewPage method.