我们有一个旧的自定义asp内部网站点,我们在其中访问我们的内部数据库,并且我设法设置了一个html页面,以便能够使用< iframe />加载其他内部网站点,如ccnet,wiki等。标签,通过页面顶部的静态菜单。
遗留代码示例:
Menu.asp:
<body topmargin="0" and leftmargin="0">
<div id="header">
<a href="default.asp" id="logo">
<img src="Images/Home.png" alt="Bam! Home" width="40" height="40"/>
</a>
<ul id="NavMenu">
<li><a>DB tasks</a>
<ul>
<li><a href="ccnet.asp?Target=RestoreBak">Restore .bak</a></li>
<li><a href="ccnet.asp?Target=RestoreSqb">Restore .sqb</a></li>
<li><a href="ccnet.asp?Target=CreateDbSnapshot">Create Snapshot</a></li>
<li><a href="ccnet.asp?Target=RevertToDbSnapshot">Revert to Snapshot</a></li>
<li><a href="ccnet.asp?Target=DeleteDbSnapshot">Delete Snapshot</a></li>
</ul>
</li>
<li><a>General</a>
<ul>
<li><a href="ccnet.asp?Target=Wiki">Wiki</a></li>
</ul>
</li>
</ul>
</div>
ccnet.asp(在iframe中加载Intranet页面以保留菜单):
<!-- #include file = "common.asp" -->
<html>
<head>
<title><%
'Common DB tasks:
if Request("Target") = "CreateDbSnapshot" then
Response.write "Create Db Snapshot"
elseif Request("Target") = "RevertToDbSnapshot" then
Response.write "Revert To Db Snapshot"
elseif Request("Target") = "DeleteDbSnapshot" then
Response.write "Delete Db Snapshot"
elseif Request("Target") = "RestoreBak" then
Response.write "Restore Bak"
elseif Request("Target") = "RestoreSqb" then
Response.write "Restore Sqb"
'General
elseif Request("Target") = "Wiki" then
Response.write "Wiki"
'Final just incase there is an unavailable option:
else
response.write "DBServer CCNet"
end if
%></title>
<link rel="stylesheet" type="text/css" href="common.css"/>
</head>
<!--#include file ="menu.asp"-->
<body>
<%
dim iFrameTargetSrc
'Common DB tasks:
if Request("Target") = "CreateDbSnapshot" then
iFrameTargetSrc = "http://DBServer/ccnet/server/local/project/1.%20Create%20DB%20Snapshot/ViewProjectReport.aspx"
elseif Request("Target") = "RevertToDbSnapshot" then
iFrameTargetSrc = "http://DBServer/ccnet/server/local/project/3.%20Delete%20DB%20Snapshot/ViewProjectReport.aspx"
elseif Request("Target") = "DeleteDbSnapshot" then
iFrameTargetSrc = "http://DBServer/ccnet/server/local/project/FS%20Backup%20SQB/ViewProjectReport.aspx"
elseif Request("Target") = "RestoreBak" then
iFrameTargetSrc = "http://DBServer/ccnet/server/local/project/Restore%20DB/ViewProjectReport.aspx"
elseif Request("Target") = "RestoreSqb" then
iFrameTargetSrc = "http://DBServer/ccnet/server/local/project/Restore%20SQB/ViewProjectReport.aspx"
'General
elseif Request("Target") = "Wiki" then
iFrameTargetSrc = "http://wiki/sites/CompanyWiki/SitePages/newhome.aspx"
'Final just incase there is an unavailable option:
else
iFrameTargetSrc = "http://DBServer/ccnet/ViewFarmReport.aspx"
response.write "Cannot find requested target " & Request("Target") & "."
end if
%>
<iframe src="<%response.write iFrameTargetSrc%>" seamless="true" frameborder="0" width="100%" height="94%"></iframe>
</body>
</html>
我们已经开始将这个传统的Intranet站点转换为MVC5,但我无法弄清楚的是如何创建一个可以在一个跨越整个视图的视图中加载ccnet和其他Intranet站点页面的视图从菜单中选择链接时的页面。视图需要来自控制器的数据。我应该如何将信息传递给控制器并加载包含非mvc内部网站点的视图?
我正在尝试将菜单选项添加到_Layout.cshtml页面,但是没有发现任何可以指向我如何实现此目的的正确方向。
任何建议,包含一个链接,可以告诉我如何使用此处发布的示例或解决方案,将受到高度赞赏。
答案 0 :(得分:0)
您可以向此类
的控制器添加操作方法public ActionResult LoadExternalSystem(string identifier)
{
switch (identifier.ToLower())
{
case "wiki":
{
ViewBag.LoadUrl = "http://wiki.somewhere";
break;
}
case "othersystem":
{
ViewBag.LoadUrl = "http://othersystem";
break;
}
}
return View();
}
然后为该操作创建一个类似于以下内容的视图
@{
ViewBag.Title = "LoadExternalSystem";
}
<iframe src="@ViewBag.LoadUrl"></iframe>
然后使用以下菜单
<ul>
<li><a href="@Url.Action("LoadExternalSystem",new {identifier="wiki"})">wiki</a></li>
<li><a href="@Url.Action("LoadExternalSystem",new {identifier="othersystem"})">Other system</a></li>
</ul>