重定向到其他网站c#的HTML页面

本文关键字:HTML 页面 网站 其他 重定向 | 更新日期: 2023-09-27 17:49:40

我想重定向到另一个网站的html页面在我的c#应用程序当用户点击一些按钮。我写了这个

Response.Redirect("http://www.fashionunic.com/shop/wholesale-m04-dozen-chevron-laced-front-top-medium.html")

但是它没有工作,抛出路径不是一个有效的虚拟路径

我在页面加载

中调用下面的方法
Response.Redirect("http://www.fashionunic.com/shop/wholesale-m04-dozen-chevron-laced-front-top-medium.html")

public void Application_BeginRequest()
{
var MyUri  = Context.Request.Url;
if(MyUri.Contains("shop/wholesale") {
            var String = MyUri.ToString();            
            Context.RewritePath("http://www.fashionunic.com/shop/wholesale-m04-dozen-chevron-laced-front-top-medium.html");
}
}
异常:

子请求的路径无效http:/www.fashionunic.com/shop/wholesale-m04-dozen-chevron-laced-front-top-medium.html"。虚拟路径

重定向到其他网站c#的HTML页面

我试过你的代码,你应该改变'Context '。重写路径'到'Response.Redirect'。应该可以的。

看这里,它可能对你有用:http://www.techrepublic.com/blog/software-engineer/two-approaches-to-redirection-in-aspnet/

同样,也许你是一个营销人员,你正在努力推广"时尚"商店:-D