#16883: Including application path in permalinks

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-11-29 13:03:55 -08:00
parent 4101cfef7e
commit 63cfef8aed
2 changed files with 30 additions and 8 deletions

View File

@@ -7,7 +7,7 @@
@Html.TextBoxFor(m => m.Title, new { @class = "large text" })
</fieldset>
<fieldset class="permalink">
<label class="sub" for="Slug">@T("Permalink")<br /><span>@Request.ToRootUrlString()/@Model.DisplayLeadingPath</span></label>
<label class="sub" for="Slug">@T("Permalink")<br /><span>@Request.ToApplicationRootUrlString()/@Model.DisplayLeadingPath</span></label>
<span>@Html.TextBoxFor(m => m.Slug, new { @class = "text" })</span>
<span class="checkbox-and-label">
@Html.EditorFor(m => m.PromoteToHomePage)

View File

@@ -1,39 +1,61 @@
using System;
using System.Web;
using System.Web.Mvc;
namespace Orchard.Utility.Extensions {
public static class HttpRequestExtensions {
/// <summary>
/// Returns the root part of a request.
/// Returns the root part of a request.
/// </summary>
/// <example>http://localhost:3030</example>
/// <remarks>Prevents port number issues by using the client requested host</remarks>
public static string ToRootUrlString(this HttpRequestBase request) {
return string.Format("{0}://{1}", request.Url.Scheme, request.Headers["Host"]);
}
/// <summary>
/// Returns the root part of a request.
/// Returns the root part of a request.
/// </summary>
/// <example>http://localhost:3030</example>
/// <remarks>Prevents port number issues by using the client requested host</remarks>
public static string ToRootUrlString(this HttpRequest request) {
return string.Format("{0}://{1}", request.Url.Scheme, request.Headers["Host"]);
}
/// <summary>
/// Returns the client requested url.
/// Returns the application root part of a request.
/// </summary>
/// <example>http://localhost:3030/OrchardLocal</example>
/// <remarks>Prevents port number issues by using the client requested host</remarks>
public static string ToApplicationRootUrlString(this HttpRequestBase request) {
string url = string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.ApplicationPath);
return url;
}
/// <summary>
/// Returns the application root part of a request.
/// </summary>
/// <example>http://localhost:3030/OrchardLocal</example>
/// <remarks>Prevents port number issues by using the client requested host</remarks>
public static string ToApplicationRootUrlString(this HttpRequest request) {
string url = string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.ApplicationPath);
return url;
}
/// <summary>
/// Returns the client requested url.
/// </summary>
/// <example>http://localhost:3030/OrchardLocal/Admin/Blogs</example>
/// <remarks>Prevents port number issues by using the client requested host</remarks>
public static string ToUrlString(this HttpRequestBase request) {
return string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.RawUrl);
}
/// <summary>
/// Returns the client requested url.
/// Returns the client requested url.
/// </summary>
/// <example>http://localhost:3030/OrchardLocal/Admin/Blogs</example>
/// <remarks>Prevents port number issues by using the client requested host</remarks>
public static string ToUrlString(this HttpRequest request) {
return string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.RawUrl);
}
}
}
}