Corrected more port issues in generated urls on Azure hosting

Was preventing Live Writer from auto onfiguring. Replace all Request.Url occurences

--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-05-17 11:59:58 -07:00
parent 3341dd863e
commit 3575e0238d
10 changed files with 39 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ using System.Web.Mvc;
using System.Web.Mvc.Html;
using Orchard.ContentManagement;
using Orchard.Localization;
using Orchard.Utility.Extensions;
namespace Orchard.Comments.Extensions {
public static class HtmlHelperExtensions {
@@ -23,7 +24,7 @@ namespace Orchard.Comments.Extensions {
Area = "Orchard.Comments",
Controller = "Admin",
id = item.Id,
returnUrl = html.ViewContext.HttpContext.Request.Url
returnUrl = html.ViewContext.HttpContext.Request.ToUrlString()
});
}

View File

@@ -2,6 +2,7 @@
<%@ Import Namespace="Orchard.Comments"%>
<%@ Import Namespace="Orchard.Security" %>
<%@ Import Namespace="Orchard.Comments.Models" %>
<%@ Import Namespace="Orchard.Utility.Extensions" %>
<%-- todo: clean up this template - waaay too much going on in here :/ --%><%
if (Model.Comments.Count > 0) { %>
<h2 id="comments"><%=_Encoded("{0} Comment{1}", Model.Comments.Count, Model.Comments.Count == 1 ? "" : "s")%></h2>
@@ -51,7 +52,7 @@ else { %>
<div>
<input type="submit" class="button" value="<%=_Encoded("Submit Comment") %>" />
<%=Html.Hidden("CommentedOn", Model.ContentItem.Id) %>
<%=Html.Hidden("ReturnUrl", Context.Request.Url) %>
<%=Html.Hidden("ReturnUrl", Context.Request.ToUrlString()) %>
<%=Html.AntiForgeryTokenOrchard() %>
</div>
</fieldset><%

View File

@@ -5,6 +5,7 @@ using JetBrains.Annotations;
using Orchard.Core.XmlRpc;
using Orchard.Core.XmlRpc.Models;
using Orchard.Security;
using Orchard.Utility.Extensions;
namespace Orchard.Media.Services {
[UsedImplicitly]
@@ -18,7 +19,7 @@ namespace Orchard.Media.Services {
}
public void Process(XmlRpcContext context) {
var uriBuilder = new UriBuilder(context.HttpContext.Request.Url) {
var uriBuilder = new UriBuilder(context.HttpContext.Request.ToUrlString()) {
Path = context.HttpContext.Request.ApplicationPath,
Query = string.Empty
};

View File

@@ -38,7 +38,7 @@ namespace Orchard.Themes.DesignerNotes {
Controller = "Admin",
context.ZoneName,
theme.ThemeName,
ReturnUrl = requestContext.HttpContext.Request.Url,
ReturnUrl = requestContext.HttpContext.Request.RawUrl,
}));
writer.Write("</div>");
}

View File

@@ -59,7 +59,7 @@ html.dyn #themepreview button.preview { display:none; }
<% using(Html.BeginFormAntiForgeryPost(Url.Action("Preview", new{Controller="Admin", Area="Orchard.Themes"}), FormMethod.Post, new { @class = "inline" })) { %>
<fieldset>
<span><%=T("You are previewing: ")%></span>
<%=Html.Hidden("ReturnUrl", Context.Request.Url)%>
<%=Html.Hidden("ReturnUrl", Context.Request.RawUrl)%>
<%=Html.DropDownList("ThemeName", Model.Themes, new {onChange = "this.form.submit();"})%>
<button type="submit" class="preview" title="<%=_Encoded("Preview")%>" name="submit.Preview" value="<%=_Encoded("Preview")%>"><%=_Encoded("Preview")%></button>
<button type="submit" title="<%=_Encoded("Apply")%>" name="submit.Apply" value="<%=_Encoded("Apply")%>"><%=_Encoded("Apply this theme") %></button>

View File

@@ -1,4 +1,5 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BaseViewModel>" %>
<%@ Import Namespace="Orchard.Utility.Extensions"%>
<%@ Import Namespace="Orchard.Mvc.Html"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%><%
var menu = Model.Menu.FirstOrDefault();
@@ -14,7 +15,7 @@
if (counter == count)
sbClass.Append("last ");
if (string.Equals(menuItem.Href, Request.Url.AbsolutePath, StringComparison.InvariantCultureIgnoreCase))
if (string.Equals(menuItem.Href, Request.ToUrlString(), StringComparison.InvariantCultureIgnoreCase))
sbClass.Append("current ");
var classValue = sbClass.ToString().TrimEnd(); %>

View File

@@ -51,7 +51,7 @@ else { %>
<div>
<input type="submit" class="button" value="<%=_Encoded("Submit Comment") %>" />
<%=Html.Hidden("CommentedOn", Model.ContentItem.Id) %>
<%=Html.Hidden("ReturnUrl", Context.Request.Url) %>
<%=Html.Hidden("ReturnUrl", Context.Request.RawUrl) %>
<%=Html.AntiForgeryTokenOrchard() %>
</div>
</fieldset><%

View File

@@ -51,7 +51,7 @@ else { %>
<div>
<input type="submit" class="button" value="<%=_Encoded("Submit Comment") %>" />
<%=Html.Hidden("CommentedOn", Model.ContentItem.Id) %>
<%=Html.Hidden("ReturnUrl", Context.Request.Url) %>
<%=Html.Hidden("ReturnUrl", Context.Request.RawUrl) %>
<%=Html.AntiForgeryTokenOrchard() %>
</div>
</fieldset><%

View File

@@ -1,5 +1,6 @@
using System;
using System.Web.Mvc;
using Orchard.Utility.Extensions;
namespace Orchard.Mvc.Extensions {
public static class UrlHelperExtensions {
@@ -8,7 +9,7 @@ namespace Orchard.Mvc.Extensions {
}
private static string MakeAbsolute(this UrlHelper urlHelper, string url) {
var siteUrl = urlHelper.RequestContext.HttpContext.Request.Url.GetLeftPart(UriPartial.Authority);
var siteUrl = urlHelper.RequestContext.HttpContext.Request.ToRootUrlString();
return siteUrl + url;
}
}

View File

@@ -2,6 +2,14 @@ using System.Web;
namespace Orchard.Utility.Extensions {
public static class HttpRequestExtensions {
/// <summary>
/// Returns the root part of a request.
/// </summary>
/// <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.
/// </summary>
@@ -9,5 +17,22 @@ namespace Orchard.Utility.Extensions {
public static string ToRootUrlString(this HttpRequest request) {
return string.Format("{0}://{1}", request.Url.Scheme, request.Headers["Host"]);
}
/// <summary>
/// Returns the client requested url.
/// </summary>
/// <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.
/// </summary>
/// <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);
}
}
}