开发者

Using Server.Transfer inside of a UserControl gives me a file not found exception

开发者 https://www.devze.com 2023-02-19 11:35 出处:网络
I\'ve tried just about every relative path that I can think of, and none of them work. Server.Transfer(\"/contact-us.aspx\");

I've tried just about every relative path that I can think of, and none of them work.

Server.Transfer("/contact-us.aspx");
Server.Transfer("./contact-us.aspx");
Server.Transfer("~/contact-us.aspx");
Server.Transfer("contact-us.aspx");

I'm pretty sure this has to do with the fact that I'm inside of an ascx UserControl. I always get "The file (my file) does not exist."

EDIT:

Also, contact-us.aspx is not a physical file. I'm using Sitecore, and this is a virtual path within the application, and the application knows how to resolve the URL开发者_开发百科.


The syntax is correct so there's likely to be a problem with the HTTPHandler / URL redirection in the SiteCore engine.

Try using Response.Redirect instead and use the overloaded version to cease all further page processing;

Response.Redirect("~/contact-us.aspx", true);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号