1

我有下一个用于从表单接收元素的代码,但问题是我想使用特定端口来检索 url。但是当我在响应重定向中键入域和端口时

Response.Redirect("http://mydomain:8888/MyApplication/default.aspx")

浏览器中的响应是:http ://mydomain.com/MyApplication/default.aspx ,没有端口号。那么,有谁知道如何将端口号传递到 url 中?

此致。

<script runat="server">

 Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

     Response.Redirect("MyApplication/default.aspx")

 End Sub
</script> 
4

1 回答 1

1

The Response.Redirect is passing the url from qualification, and they correct the url if its not in the form of http://server/path

You can ether disable this qualification using the useFullyQualifiedRedirectUrl property, ether make a custom redirect.

So ether UseFullyQualifiedRedirectUrl=false, as MSDN says, ether just use this function for redirect:

public static void CustomRedirect(string url, bool endResponse)
{
    HttpResponse cResponce = HttpContext.Current.Response;

    cResponce.Clear();
    cResponce.TrySkipIisCustomErrors = true;
    cResponce.StatusCode = 302;
    cResponce.Status = "302 Temporarily Moved";
    cResponce.RedirectLocation = url;

    cResponce.Write("<html><head><title>Object moved</title></head><body>\r\n");
    cResponce.Write("<h2>Object moved to <a href=\"" + url + "\">here</a>.</h2>\r\n");
    cResponce.Write("</body></html>\r\n");

    if (endResponse){
        cResponce.End();
    }
}

This function is a cut off version of the Redirect function of asp.net

于 2012-11-20T10:30:57.957 回答