-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathUrl.cs
36 lines (35 loc) · 1.12 KB
/
Url.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Moon.Mvc
{
public static class Url
{
public static string Content(string virtrualPath)
{
string ret = virtrualPath.Replace("~", UrlRouteCenter.ROOT_URL);
return ret;
}
public static string Action<TController>(string action) where TController : BaseController
{
var url = UrlUtil.Action<TController>(action);
return url;
}
public static string Action<TController>(string action, object datas) where TController : BaseController
{
var dic = MHtmlHelper<object>.AnonymousObjectToHtmlAttributes(datas);
var url = UrlUtil.Action<TController>(action);
if (dic.Count > 0)
{
url = url + "?";
foreach (var kvp in dic)
{
url += kvp.Key + "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()) + "&";
}
url = url.TrimEnd('&');
}
return url;
}
}
}