0

我已经开发了常规的 ASP Web 应用程序以部署在 IIS 服务器下作为与端口 xxxx 绑定的新网站,然后客户需要在默认网站(端口 80)下的 Web 服务器上发布此站点

问题是所有链接和重定向网址都在母版页中硬编码,有时在代码后面

我的问题是修改代码以在 IIS 服务器下(在默认网站(端口 80)下和作为带有 prot xxxx 的新网站)下以两种方式工作的最佳方法是什么?

像:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MainMaster.Master.cs"     Inherits="xxxx.MainMaster" %>

<!DOCTYPE html>
<link href="/App_Themes/styles.css" rel="stylesheet" />
<link href="/App_Themes/colorbox.css" rel="stylesheet" />

<script type="text/javascript" src="/Scripts/jquery-1.7.2.min.js"></script>
<script src="/Scripts/jquery.textarea.js"></script>
<script src="/Scripts/jquery.colorbox-min.js"></script>
<script src="/Scripts/jquery.colorbox.js"></script>
<script src="/Scripts/jquery-ui-1.10.2.custom.min.js"></script>
<link href="/App_Themes/jquery-ui-1.10.2.custom.min.css" rel="stylesheet" />

和后面的代码一样

try
{
   Response.Redirect("/Applications/Default.aspx");
}
catch (Exception ex)
{
   Helper.LogException(ex);
}

在一些asp页面中,jquery:function ShowColorBox(id) {

    //var reqId = name.reqid;
    // get Request ID from hidden field
    var imageBtn = $("#" + id);
    var requestId = imageBtn.attr('reqid');

    // attach color box to Request Details
    imageBtn.colorbox({ iframe: true, width: "680px", height: "95%", href: "/Applications/Requests/RequestDetails.aspx?ItemID=" + requestId });


}
4

2 回答 2

0

The easiest solution would be to add an binding of the default web site to the port needed. This can be done with two or three clicks in the IIS-Manager.

The clean way is to use ~/ and runat="server" wherever you need a link.

于 2013-06-09T10:42:24.487 回答
0

My solution to work around this problem is as following: 1- in Master page I write links like this <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MainMaster.Master.cs" Inherits="xxxx.MainMaster" %>

<!DOCTYPE html>
<link href='<%= ResolveClientUrl("~/App_Themes/styles.css") %>' rel="stylesheet" />
<link href='<%= ResolveClientUrl("~/App_Themes/colorbox.css") %>' rel="stylesheet" />

<script type="text/javascript" src='<%= ResolveClientUrl("~/Scripts/jquery-1.7.2.min.js") %>'></script>
<script src='<%= ResolveClientUrl("~/Scripts/jquery.textarea.js") %>'></script>
<script src='<%= ResolveClientUrl("~/Scripts/jquery.colorbox-min.js") %>'></script>
<script src='<%= ResolveClientUrl("~/Scripts/jquery.colorbox.js") %>'></script>
<script src='<%= ResolveClientUrl("~/Scripts/jquery-ui-1.10.2.custom.min.js") %>'>    </script>
<link href='<%= ResolveClientUrl("~/App_Themes/jquery-ui-1.10.2.custom.min.css") %>' rel="stylesheet" />

2- in code behind

 Response.Redirect("~/Applications/Default.aspx");

3- in asp pages: function ShowColorBox(id) {

    //var reqId = name.reqid;
    // get Request ID from hidden field
    var imageBtn = $("#" + id);
    var requestId = imageBtn.attr('reqid');

    // attach color box to Request Details
    imageBtn.colorbox({ iframe: true, width: "680px", height: "95%", href: '<%= ResolveClientUrl("~/Applications/Requests/RequestDetails.aspx?ItemID=") %>' + requestId });

}
于 2013-06-09T19:54:43.960 回答