从一个Web项目的Response.Redirect到另一个在Visual Studio [英] Response.Redirect from one web project to another in Visual Studio

查看:139
本文介绍了从一个Web项目的Response.Redirect到另一个在Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图项目集成到pre-现有的解决方案。

I am attempting to integrate a project into a pre-existing solution.

在溶液中的启动项目名为foo。它被写入的虚拟路径/ csweb /。当这个项目启动时加载/csweb/Default.aspx。这是当前的,未经修改的主页。

The start-up project in the solution is named "Foo." It is written to the virtual path "/csweb/." When this project starts up it loads /csweb/Default.aspx. This is the current, unmodified home page.

我试图重定向到一个不同的主页在不同的项目中。

I am attempting to redirect to a different home page in a different project.

我添加了第二个项目名为解栏。根据其项目属性我告诉它写入虚拟路径/ csweb /。它未标记为启动项目,也没有多启动项目 - 只是富。在酒吧被标记为启动项目栏的主页访问。它的主页是由重新本地主机psented $ P $:端口/ csweb / Default.aspx的

I added a second project to the solution named "Bar." Under its project properties I told it to write to the virtual path "/csweb/." It is not marked as the start-up project, nor are there multiple start-up projects -- just Foo. Bar's homepage is accessible when Bar is marked as the start-up project. It's homepage is represented by localhost:port/csweb/Default.aspx

我想同时使用美孚作为初创项目重定向到酒吧的Default.aspx的。我很好的重新命名酒吧的Default.aspx的东西无歧义的,如果这将使问题更加容易。

I would like to redirect to Bar's Default.aspx while using Foo as the start-up project. I am fine with renaming Bar's Default.aspx to something non-ambiguous, if that would make the problem easier.

如果我尝试 HttpContext.Response.Redirect(〜/ Default.aspx的)那么它显然需要我美孚/ Default.aspx的,而不是酒吧/默认。 ASPX,但在浏览器的网址只是本地主机:端口/ csweb / Default.aspx的。不存在是一个项目,完全可以理解的内部指示。如果我重新命名酒吧/ Default.aspx的到酒吧/ UniqueName.aspx并尝试 HttpContext.Response.Redirect(〜/ UniqueName.aspx)然后在页面没有找到。

If I try HttpContext.Response.Redirect("~/Default.aspx") then it clearly takes me to Foo/Default.aspx and not Bar/Default.aspx, but the url in the browser is just localhost:port/csweb/Default.aspx. There is no indication of being inside of a project, completely understandable. If I rename Bar/Default.aspx to Bar/UniqueName.aspx and attempt HttpContext.Response.Redirect("~/UniqueName.aspx") then the page is not found.

这里有什么正确的电话吗?我是否需要设置酒吧为pre-存在于IIS虚拟目录,以便我可以指定一个完整的路径名,以避免歧义?还是我需要做一些花哨的多启动Web项目,以便它可访问?

What's the right call here? Do I need to setup Bar as a pre-existing virtual directory in IIS so that I can specify a more complete path name to avoid ambiguity? Or do I need to do something fancy with multiple start-up web projects in order for it to be accessible?

感谢您对这个困惑的问题的任何意见。

Thanks for any advice on this confusing issue.

编辑:我最终只是增加另一个文件夹以Foo的项目和酒吧的项目的内容移动到该文件夹​​。我就能够做到 HttpContext.Response.Redirect(〜/酒吧/酒吧的Default.aspx的)我还是很乐意听到比这更好的解决方案,但!

I ended up just adding another folder to Foo's project and moving the contents of Bar's project to this folder. I am then able to do HttpContext.Response.Redirect("~/Bar/Bar's Default.aspx") I'd still love to hear a better solution than this, though!

推荐答案

尝试 HttpContext.Response.Redirect(/ csweb / Default.aspx的)。在当前的重定向波浪线〜说,在这个应用程序的主文件夹启动。通过删除您可以重定向到其他位置上你的网站。

Try HttpContext.Response.Redirect("/csweb/Default.aspx"). The tilde "~" in your current redirect says to start in this application's home folder. By removing that you can redirect to some other location on your site.

您也可以完全限定重定向如果你希望去到一个完全不同的网站。

You can also fully qualify the redirect to go to an entirely different site if you wish.

这篇关于从一个Web项目的Response.Redirect到另一个在Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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