如何在运行时创建URL .. [英] How URLs are created at runtime..

查看:101
本文介绍了如何在运行时创建URL ..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个问答网站,就像在所有网站上一样,例如stackoverflow.com,codeproject.com,浏览器中的Urls,每个问题的答案都不同。所以我只需要一个演示样本/代码。

解决方案

这项技术被称为url重写,如果你谷歌搜索asp.net url rewriting之类的东西网址中的问题你会找到例子。如果您正在使用MVC,那么您可以更轻松地使用路由将问题令牌添加为操作的参数,然后您只需将其转换为某种类型的问题ID。



http://www.asp.net/mvc/overview/older-versions-1/controllers-and-routing/asp-net-mvc-routing-overview-cs [ ^

I want to create a Question Answer website , like in all website like stackoverflow.com, codeproject.com, Urls in the browser for every question-answers are different. So i just need a demo sample/code of that.

解决方案

The technique is called "url rewriting", if you google for something like "asp.net url rewriting question in url" you'll find examples. If you're using MVC then it's easier as you can employ routing to add the question token as a param to the action, which you then just need to convert into a question id of some sort.

http://www.asp.net/mvc/overview/older-versions-1/controllers-and-routing/asp-net-mvc-routing-overview-cs[^]


这篇关于如何在运行时创建URL ..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆