C# MVC中挂接HTML页面

时间:2022-06-30 05:09:03

需求:word另存为html  getResult.html,挂接在c# .net mvc 框架 中,,点击超链接在系统中展现html页面

方法:

1、在Web.config 中添加如下代码

<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<buildProviders>
<add extension=".htm" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>

2、然后在controller中编写方法跳转到相应的aspx页面

public ActionResult GetResult(){

  return View();

}

3、在getResult.aspx页面编写如下代码:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<div>
<%Html.RenderPartial("~/Views/Home/GetResult.htm");%>
</div>
</body>
</html>