Asp.net 将端口号传递到响应重定向中

Asp.net 将端口号传递到响应重定向中,asp.net,vb.net,Asp.net,Vb.net,我有从表单接收元素的下一个代码,但问题是我想使用特定的端口来检索url。但是当我在响应重定向中键入域和端口时 Response.Redirect("http://mydomain:8888/MyApplication/default.aspx") 浏览器中的响应为:不带端口号。那么,有人知道如何将端口号传递到url吗 致以最良好的祝愿 <script runat="server"> Private Sub Button1_Click(ByVal sender As Object

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

Response.Redirect("http://mydomain:8888/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> 

私有子按钮1\u单击(ByVal sender作为对象,ByVal e作为System.EventArgs)
重定向(“MyApplication/default.aspx”)
端接头

响应.重定向
是从限定传递url,如果url不是
http://server/path

您可以使用以太禁用此限定,进行自定义重定向

所以Ethernet
UsefullyQualifiedDirectUrl=false
,正如MSDN所说,Ethernet只需使用此函数进行重定向:

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();
    }
}
publicstaticvoidcustomredirect(字符串url,bool-endResponse)
{
HttpResponse responce=HttpContext.Current.Response;
清晰的;
creponce.tryskipiiscustomerors=true;
responce.StatusCode=302;
responce.Status=“302临时移动”;
responce.RedirectLocation=url;
Write(“对象已移动\r\n”);
Write(“对象移动到。\r\n”);
响应写入(“\r\n”);
if(endResponse){
结束();
}
}

此函数是asp.net重定向函数的截止版本,
响应。重定向是从限定传递url,如果url不是
http://server/path

您可以使用以太禁用此限定,进行自定义重定向

所以Ethernet
UsefullyQualifiedDirectUrl=false
,正如MSDN所说,Ethernet只需使用此函数进行重定向:

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();
    }
}
publicstaticvoidcustomredirect(字符串url,bool-endResponse)
{
HttpResponse responce=HttpContext.Current.Response;
清晰的;
creponce.tryskipiiscustomerors=true;
responce.StatusCode=302;
responce.Status=“302临时移动”;
responce.RedirectLocation=url;
Write(“对象已移动\r\n”);
Write(“对象移动到。\r\n”);
响应写入(“\r\n”);
if(endResponse){
结束();
}
}

此函数是asp.net重定向函数的截止版本

是否确实要传递给响应的内容。重定向确实是您认为的url?上述代码显然不是真正的代码,因为它缺少
围绕字符串,因此我想知道您是否传递的变量可能不是您认为的值。。。我当然希望上面的内容能在我个人身上起作用,尽管我可能对这个期望是错误的……我想你只是在你的url前面缺少了一个“/”,比如“/MyApplication/default.aspx”,一切都会按预期开始工作对不起,我已经添加了“,我错过了它们。您确定要传递给响应的内容。重定向确实是您认为的url吗?上述代码显然不是真正的代码,因为它缺少
围绕字符串,因此我想知道您是否传递的变量可能不是您认为的值。。。我当然希望上面的内容能在我个人身上起作用,尽管我可能对这个期望是错误的……我想你只是在你的url前面缺少了一个“/”,比如“/MyApplication/default.aspx”,一切都会按预期开始工作对不起,我已经添加了“,我错过了他们,我不知道如何实施它。我如何在我的代码中做到这一点?@FranRod更改此
响应。重定向(“http://mydomain:8888/MyApplication/default.aspx“
使用此
自定义重定向(”http://mydomain:8888/MyApplication/default.aspx“,是的)
我不知道如何实现它。我如何在我的代码中做到这一点?@FranRod更改此
响应。重定向(“http://mydomain:8888/MyApplication/default.aspx“
使用此
自定义重定向(”http://mydomain:8888/MyApplication/default.aspx“,正确)