-
Notifications
You must be signed in to change notification settings - Fork 6
/
PageResult.cs
62 lines (57 loc) · 1.25 KB
/
PageResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* 由SharpDevelop创建。
* 用户: qscq
* 日期: 2014/8/24
* 时间: 17:07
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
using System.IO;
using System.Web;
using System.Web.Compilation;
using System.Web.UI;
namespace Moon.Web
{
/// <summary>
/// 表示一个页面结果(页面将由框架执行)
/// </summary>
public sealed class PageResult: IResult
{
/// <summary>
/// 页面所在的虚拟路径
/// </summary>
public string VirtualPath
{
get;
private set;
}
/// <summary>
/// 页面所用Model
/// </summary>
public object Model
{
get;
private set;
}
HttpContext _context;
public PageResult(string virtualPath, object model,BaseController controller)
{
this.VirtualPath = virtualPath;
this.Model = model;
_context=controller.CurrentHttpContext;
WriteToHttpResponse(_context);
}
public void WriteToHttpResponse(HttpContext context)
{
if( string.IsNullOrEmpty(this.VirtualPath))
{
this.VirtualPath = context.Request.FilePath;
}
context.Response.ContentType = "text/html";
string html = RenderUtil.RenderAspx(context,VirtualPath,Model);
context.Response.Write(html);
context.Response.End();
}
}
}