1. 程式人生 > >C# MVC中掛接HTML頁面

C# MVC中掛接HTML頁面

deb mvc geb .org 點擊 its sem web partial

需求: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>

C# MVC中掛接HTML頁面