在默认网站(端口80)和新网站(端口xxxx)同时托管asp web应用程序的最佳方法是什么?
本文关键字:网站 端口 asp 应用程序 web 方法 是什么 最佳 默认 新网站 xxxx | 更新日期: 2023-09-27 18:17:40
我开发了常规的asp web应用程序,部署在IIS服务器下作为绑定端口xxxx的新网站,然后客户需要在默认网站(端口80)下的web服务器上发布该网站
问题是所有的链接和重定向url都硬编码在母版页中,有时在 后面的代码中我的问题是什么是最好的方式来修改代码工作在IIS服务器下的两种方式(在默认网站(端口80)和端口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: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 });
}
最简单的解决方案是将默认网站的绑定添加到所需的端口。这可以通过在IIS-Manager中单击两到三次来完成。
干净的方法是在需要链接的地方使用~/和runat="server"
我对这个问题的解决方案如下:1-在主页我写这样的链接<%@ Master Language=" c# " AutoEventWireup="true" CodeBehind="MainMaster.Master.cs" Inherits="xxxx. c# "主桅"%>
<!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代码 Response.Redirect("~/Applications/Default.aspx");
3- in asp页面: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 });
}