mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
@@ -7,7 +7,7 @@
|
|||||||
@Html.TextBoxFor(m => m.Title, new { @class = "large text" })
|
@Html.TextBoxFor(m => m.Title, new { @class = "large text" })
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="permalink">
|
<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>@Html.TextBoxFor(m => m.Slug, new { @class = "text" })</span>
|
||||||
<span class="checkbox-and-label">
|
<span class="checkbox-and-label">
|
||||||
@Html.EditorFor(m => m.PromoteToHomePage)
|
@Html.EditorFor(m => m.PromoteToHomePage)
|
||||||
|
@@ -1,39 +1,61 @@
|
|||||||
using System;
|
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
|
||||||
|
|
||||||
namespace Orchard.Utility.Extensions {
|
namespace Orchard.Utility.Extensions {
|
||||||
public static class HttpRequestExtensions {
|
public static class HttpRequestExtensions {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the root part of a request.
|
/// Returns the root part of a request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <example>http://localhost:3030</example>
|
||||||
/// <remarks>Prevents port number issues by using the client requested host</remarks>
|
/// <remarks>Prevents port number issues by using the client requested host</remarks>
|
||||||
public static string ToRootUrlString(this HttpRequestBase request) {
|
public static string ToRootUrlString(this HttpRequestBase request) {
|
||||||
return string.Format("{0}://{1}", request.Url.Scheme, request.Headers["Host"]);
|
return string.Format("{0}://{1}", request.Url.Scheme, request.Headers["Host"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the root part of a request.
|
/// Returns the root part of a request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <example>http://localhost:3030</example>
|
||||||
/// <remarks>Prevents port number issues by using the client requested host</remarks>
|
/// <remarks>Prevents port number issues by using the client requested host</remarks>
|
||||||
public static string ToRootUrlString(this HttpRequest request) {
|
public static string ToRootUrlString(this HttpRequest request) {
|
||||||
return string.Format("{0}://{1}", request.Url.Scheme, request.Headers["Host"]);
|
return string.Format("{0}://{1}", request.Url.Scheme, request.Headers["Host"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the client requested url.
|
/// Returns the application root part of a request.
|
||||||
/// </summary>
|
/// </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>
|
/// <remarks>Prevents port number issues by using the client requested host</remarks>
|
||||||
public static string ToUrlString(this HttpRequestBase request) {
|
public static string ToUrlString(this HttpRequestBase request) {
|
||||||
return string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.RawUrl);
|
return string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.RawUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the client requested url.
|
/// Returns the client requested url.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <example>http://localhost:3030/OrchardLocal/Admin/Blogs</example>
|
||||||
/// <remarks>Prevents port number issues by using the client requested host</remarks>
|
/// <remarks>Prevents port number issues by using the client requested host</remarks>
|
||||||
public static string ToUrlString(this HttpRequest request) {
|
public static string ToUrlString(this HttpRequest request) {
|
||||||
return string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.RawUrl);
|
return string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.RawUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user