/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Web.Mvc;
using System.Web.Routing;
using Everest.Library;
namespace Everest.Library.ExtensionMethod{
public static class UrlHelperExtensions
{
public static string ActionEx(this UrlHelper urlHelper, string actionName, NameValueCollection values)
{
RouteValueDictionary valueDic = new RouteValueDictionary();
foreach (string n in values.AllKeys)
{
valueDic.Add(n, values[n]);
}
return urlHelper.Action(actionName, valueDic);
}
public static string ResolveUrl(this UrlHelper urlHelper, string url)
{
EverestContext context = EverestContext.GetContext();
string fullUrl = url.Replace("~/", context.BaseUrl);
string applicationPath = urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
if (!applicationPath.EndsWith("/"))
{
applicationPath = applicationPath + "/";
}
string clientUrl = fullUrl.Replace("~/", applicationPath);
////only use on cms.
//if (!EverestContext.GetContext().VisitByHostName && !string.IsNullOrEmpty(EverestContext.GetContext().CmsApplicationName))
//{
// url = string.Format("/c-{0}{1}", EverestContext.GetContext().CmsApplicationName, url);
//}
return clientUrl;
}
}
}
|