简体   繁体   English

Server.Transfer不传送某些网址

[英]Server.Transfer not tranfer some urls

i use server.transfer at the begining it works perfectly. 我在一开始就使用server.transfer,它可以正常工作。 but then i add another language to my site and i try to do it but it fails with the new language 但是后来我在网站上添加了另一种语言,但我尝试这样做,但是新语言失败了

my code is below 我的代码如下

   if (Request.RawUrl.Contains("/tr/"))
   {
         Server.Transfer("tr/" + dt.Rows[0]["SourceURL"].ToString());

    }
    else if (Request.RawUrl.Contains("/en/"))
    {
        Server.Transfer("en/" + dt.Rows[0]["SourceURL"].ToString());

    }

the "tr" transfers work superb but en fails it stays on my pagenotfound and not transfer to the destination url. “ tr”传输效果很好,但是en失败,它停留在我的pagenotfound上,并且没有传输到目标URL。 i also check to write the whole url like http://mysite.com/en/test.aspx?k=13 and it also works but when server.transfer it fails 我还检查写整个URL,例如http://mysite.com/en/test.aspx?k=13 ,它也可以正常工作,但是当server.transfer失败时

can anybody say why? 有人可以说为什么吗?

thanks 谢谢

I think Response.Redirect will work for in your situation for the website " www.mysite.com/en/home" 我认为Response.Redirect将根据您的情况适用于网站“ www.mysite.com/en/home”

It won't be as efficient as Server.Transfer, but should work just as well. 它不会像Server.Transfer那样高效,但是应该也能正常工作。 I'm not sure why it works with "tr/", but not "en/", this might be due to some issue with relative paths. 我不确定为什么它与“ tr /”一起使用,而不与“ en /”一起使用,这可能是由于相对路径引起的。 You could try to include a tilda "~" in front of your URL. 您可以尝试在URL前面加上一个tilda“〜”。

      Server.Transfer("~/en/" + dt.Rows[0]["SourceURL"].ToString());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM