Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c483edd

Browse files
committedOct 31, 2017
Resolve ASP.NET environments without HTTP contexts
1 parent 36c653f commit c483edd

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed
 

‎src/React.Web/AspNetCache.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ public class AspNetCache : ICache
2828
/// <summary>
2929
/// Initializes a new instance of the <see cref="AspNetCache"/> class.
3030
/// </summary>
31-
/// <param name="context">The HTTP context</param>
32-
public AspNetCache(HttpContextBase context)
31+
public AspNetCache()
3332
{
34-
_cache = context.Cache;
33+
_cache = HttpRuntime.Cache;
3534
}
3635

3736
/// <summary>

‎src/React.Web/AspNetFileSystem.cs

+2-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
using System.Web;
10+
using System.Web.Hosting;
1111

1212
namespace React.Web
1313
{
@@ -17,28 +17,14 @@ namespace React.Web
1717
/// </summary>
1818
public class AspNetFileSystem : FileSystemBase
1919
{
20-
/// <summary>
21-
/// The ASP.NET server utilities
22-
/// </summary>
23-
private readonly HttpServerUtilityBase _serverUtility;
24-
25-
/// <summary>
26-
/// Initializes a new instance of the <see cref="AspNetFileSystem"/> class.
27-
/// </summary>
28-
/// <param name="serverUtility">The server utility.</param>
29-
public AspNetFileSystem(HttpServerUtilityBase serverUtility)
30-
{
31-
_serverUtility = serverUtility;
32-
}
33-
3420
/// <summary>
3521
/// Converts a path from an application relative path (~/...) to a full filesystem path
3622
/// </summary>
3723
/// <param name="relativePath">App-relative path of the file</param>
3824
/// <returns>Full path of the file</returns>
3925
public override string MapPath(string relativePath)
4026
{
41-
return _serverUtility.MapPath(relativePath);
27+
return HostingEnvironment.MapPath(relativePath);
4228
}
4329
}
4430
}

0 commit comments

Comments
 (0)
Please sign in to comment.