在旧的asp系统之上使用asp.net路由

发布于 2024-10-17 12:02:15 字数 754 浏览 3 评论 0原文

我正在尝试使用 MVC 路由作为临时修复,以便在旧系统(VB6/ASP 经典)被重写时(这将需要很长时间)获得 SEO 友好的 url。

旧系统有 1 个带有 vb6 dll 的 asp 文件,该 dll 生成 html,由 master.asp 中的 response.write 提供服务。

所以该系统上的网址如下所示:
www.foo.com/master.asp?sessionid=abc123&pagetype=Item&ItemID=My-widget

我想知道是否可以使用 MVC 项目来创建更清晰 URL 的路由 并让控制器映射值并构建相应的旧 url,然后对其执行 Server.Transfer。

所以新的网址将如下所示:
www.foo.com/Item/My-widget

并映射到旧网址
www.foo.com/master.asp?sessionid=abc123&pagetype=Item&ItemID=My-widget

两者都可以互换使用,因此现有站点不必更改,但我可以在外部网站上使用新的更干净的 url 以获得更好的 SEO

这可能吗? 还有其他方法可以做到这一点吗?

编辑: 由于无法从 MVC 使用 server.transfer,我现在正在考虑在 ASP.net Webforms 应用程序中使用路由。 这应该允许我完成应用程序的路由部分。一旦我尝试过,就会发回这里。

I'm experimenting with using MVC routing as a temporary fix to get SEO friendly urls on an old (VB6/ASP classic) system while it's being re-written (which will take a long time).

The old system has 1 asp file with a vb6 dll that generates html which is served by a response.write in the master.asp.

so urls on that system look like this:
www.foo.com/master.asp?sessionid=abc123&pagetype=Item&ItemID=My-widget

I'm wondering if I can use an MVC project to create a route for cleaner urls
and have a controller map the values and build the corresponding old url and then do a Server.Transfer to it.

So the new url would look like:
www.foo.com/Item/My-widget

and map to the old url at
www.foo.com/master.asp?sessionid=abc123&pagetype=Item&ItemID=My-widget

both could then be used interchangeably so the existing site doesn;t have to change, but I could use the new cleaner url on external sites for better SEO

Is this possible?
Is there another way to do this?

edit:
since it's not possible to use server.transfer from MVC, I'm now considering using routing in an ASP.net webforms app.
This should allow me to get the routing part of the application done. Will post back here once I've tried it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不打扰别人 2024-10-24 12:02:15

我建议您改用 UrlRewriter.net 库。它比内置路由框架有更多的功能(包括正则表达式支持),支持永久重定向,并且所有这些都可以在 web.config 文件中进行配置。

我之前曾尝试使用路由来处理此类事情,但发现它很快就变得非常有限。

http://urlrewriter.net/

编辑:您仍然需要一个 .net Web 项目“包装器”来用于您的经典 asp不过,正如您在问题中所描述的那样,解决方案当然会带来其他答案中概述的自身问题。

I would suggest you use UrlRewriter.net library instead. It has a lot more features than the the built-in Routing framework (including Regex support), support for permanent redirects, and it's all configurable in the web.config file.

I've tried to use Routing before for this sort of thing but found that it became quite limiting very quickly.

http://urlrewriter.net/

Edit: you will still need a .net web project "wrapper" for your classic asp solution though, as you describe in your question, which of course comes with it's own problems as outlined in the other answers.

内心旳酸楚 2024-10-24 12:02:15

我想不出一种方法可以做到这一点,但你可能会在 iis 中的 url 重写器模块中遇到一些运气: http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

I cant think of a way that you could do this, but you might have some luck with the url rewriter module in iis: http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

甚是思念 2024-10-24 12:02:15

我认为这可以发挥作用,但听起来并不理想。我怀疑您在两个会话之间共享数据时也会遇到一些问题。如果您计划迁移到 .net,并且该应用程序将在“一半对一半”的状态下运行一段时间,这可能是一个好主意(如果是这样,我建议在双方之前引入一个在双方之间共享的托管核心库)担心 url 重写)。

我最近没有做太多关于经典 ASP 的工作,但我认为这篇文章 经典 ASP 中的 URL 重写可能对您有帮助。

I think this could be made to work, but it doesn't sound ideal. I suspect you'd run into some issues with sharing data between the two sessions too. It may be a good idea IF you are planning to migrate to .net, and the app will be running in a "half and half" state for a while (if so I'd suggest introducing a managed core library shared between both sides before worrying about url rewrites).

I haven't done much work with classic ASP lately, but I think this post on URL Rewriting in Classic ASP might be helpful to you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文