forked from maartenba/MvcSiteMapProvider
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for issue maartenba#14 (Use GET to determine node accessibility).
Adds 'routeMethod' attribute to sitemap provider initialization attributes. The value set in the attribute is used when determining current route. If the value is empty or not specified the method of the current request is used.
- Loading branch information
Max Kiselev
committed
Aug 8, 2012
1 parent
e7fc03c
commit 1b72c3a
Showing
6 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/MvcSiteMapProvider/MvcSiteMapProvider/External/HttpContextMethodOverrider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#region Using directives | ||
|
||
using System; | ||
using System.Web; | ||
|
||
#endregion | ||
|
||
namespace MvcSiteMapProvider.External | ||
{ | ||
/// <summary> | ||
/// Wraps an <see cref="HttpContext"/> and overrides <see cref="HttpRequestBase.HttpMethod"/> | ||
/// value of the <see cref="Request"/> property. | ||
/// </summary> | ||
public class HttpContextMethodOverrider : HttpContextWrapper | ||
{ | ||
private readonly HttpContext httpContext; | ||
|
||
private readonly string httpMethod; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HttpContextMethodOverrider"/> class. | ||
/// </summary> | ||
/// <param name="httpContext">The object that this wrapper class provides access to.</param> | ||
/// <param name="httpMethod"> | ||
/// The <see cref="HttpRequestBase.HttpMethod"/> override value or <c>null</c> if the value | ||
/// should not be overriden. | ||
/// </param> | ||
/// <exception cref="T:System.ArgumentNullException"> | ||
/// <paramref name="httpContext"/> is null. | ||
/// </exception> | ||
public HttpContextMethodOverrider(HttpContext httpContext, string httpMethod) | ||
: base(httpContext) | ||
{ | ||
this.httpContext = httpContext; | ||
this.httpMethod = httpMethod; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the <see cref="T:System.Web.HttpRequestBase"/> object for the current HTTP request. | ||
/// </summary> | ||
/// <value></value> | ||
/// <returns> | ||
/// The current HTTP request. | ||
/// </returns> | ||
public override HttpRequestBase Request | ||
{ | ||
get { return new HttpRequestMethodOverrider(this.httpContext.Request, httpMethod); } | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/MvcSiteMapProvider/MvcSiteMapProvider/External/HttpRequestMethodOverrider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#region Using directives | ||
|
||
using System; | ||
using System.Reflection; | ||
using System.Web; | ||
|
||
#endregion | ||
|
||
namespace MvcSiteMapProvider.External | ||
{ | ||
/// <summary> | ||
/// Wraps an <see cref="HttpRequest"/> and overrides <see cref="HttpMethod"/> value. | ||
/// </summary> | ||
public class HttpRequestMethodOverrider : HttpRequestWrapper | ||
{ | ||
private readonly string httpMethod; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HttpRequest2"/> class. | ||
/// </summary> | ||
/// <param name="httpRequest">The object that this wrapper class provides access to.</param> | ||
/// <param name="httpMethod">The <see cref="HttpMethod"/></param> | ||
/// <exception cref="T:System.ArgumentNullException"> | ||
/// <paramref name="httpRequest"/> is null. | ||
/// </exception> | ||
public HttpRequestMethodOverrider(HttpRequest httpRequest, string httpMethod) | ||
: base(httpRequest) | ||
{ | ||
this.httpMethod = httpMethod; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the HTTP data-transfer method (such as GET, POST, or HEAD) that was used by the client. | ||
/// </summary> | ||
/// <returns> | ||
/// The HTTP data-transfer method that was used by the client. | ||
/// </returns> | ||
public override string HttpMethod | ||
{ | ||
get { return this.httpMethod ?? base.HttpMethod; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters