diff --git a/Sources/SrkToolkit.Domain.AspNetCore2/SrkToolkit.Domain.AspNetCore2.csproj b/Sources/SrkToolkit.Domain.AspNetCore2/SrkToolkit.Domain.AspNetCore2.csproj
index e8d61d5..65ca043 100644
--- a/Sources/SrkToolkit.Domain.AspNetCore2/SrkToolkit.Domain.AspNetCore2.csproj
+++ b/Sources/SrkToolkit.Domain.AspNetCore2/SrkToolkit.Domain.AspNetCore2.csproj
@@ -1,9 +1,8 @@
- net7.0
- enable
- enable
+ disable
+ disable
SrkToolkit.Domain.AspNetCore2
true
2.0.147-preview2
@@ -19,6 +18,7 @@
true
..\SrkToolkit.snk
SrkToolkit.Domain.md
+ net7.0;netstandard2.0
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpContext.cs b/Sources/SrkToolkit.Web.AspMvc5/Fakes/BasicHttpContext.cs
similarity index 94%
rename from Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpContext.cs
rename to Sources/SrkToolkit.Web.AspMvc5/Fakes/BasicHttpContext.cs
index d49ecd1..f4d6944 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpContext.cs
+++ b/Sources/SrkToolkit.Web.AspMvc5/Fakes/BasicHttpContext.cs
@@ -16,17 +16,17 @@
namespace SrkToolkit.Web.Fakes
{
- using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
+ using System.Web;
///
/// Implementation of where the developer can set any property to any value.
///
- public class BasicHttpContext : HttpContext
+ public class BasicHttpContext : HttpContextBase
{
private HttpSessionStateBase session;
private IPrincipal user;
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpRequest.cs b/Sources/SrkToolkit.Web.AspMvc5/Fakes/BasicHttpRequest.cs
similarity index 100%
rename from Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpRequest.cs
rename to Sources/SrkToolkit.Web.AspMvc5/Fakes/BasicHttpRequest.cs
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpSessionState.cs b/Sources/SrkToolkit.Web.AspMvc5/Fakes/BasicHttpSessionState.cs
similarity index 100%
rename from Sources/SrkToolkit.Web.AspNetCore2/Fakes/BasicHttpSessionState.cs
rename to Sources/SrkToolkit.Web.AspMvc5/Fakes/BasicHttpSessionState.cs
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/Filters/AuthorizeAttribute.cs b/Sources/SrkToolkit.Web.AspMvc5/Filters/AuthorizeAttribute.cs
similarity index 100%
rename from Sources/SrkToolkit.Web.AspNetCore2/Filters/AuthorizeAttribute.cs
rename to Sources/SrkToolkit.Web.AspMvc5/Filters/AuthorizeAttribute.cs
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/BasicHttpErrorResponse.cs b/Sources/SrkToolkit.Web.AspMvc5/HttpErrors/BasicHttpErrorResponse.cs
similarity index 100%
rename from Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/BasicHttpErrorResponse.cs
rename to Sources/SrkToolkit.Web.AspMvc5/HttpErrors/BasicHttpErrorResponse.cs
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/ErrorControllerHandler.cs b/Sources/SrkToolkit.Web.AspMvc5/HttpErrors/ErrorControllerHandler.cs
similarity index 100%
rename from Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/ErrorControllerHandler.cs
rename to Sources/SrkToolkit.Web.AspMvc5/HttpErrors/ErrorControllerHandler.cs
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/IErrorController.cs b/Sources/SrkToolkit.Web.AspMvc5/HttpErrors/IErrorController.cs
similarity index 100%
rename from Sources/SrkToolkit.Web.AspNetCore2/HttpErrors/IErrorController.cs
rename to Sources/SrkToolkit.Web.AspMvc5/HttpErrors/IErrorController.cs
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/JsonNetResult.cs b/Sources/SrkToolkit.Web.AspMvc5/JsonNetResult.cs
similarity index 94%
rename from Sources/SrkToolkit.Web.AspNetCore2/JsonNetResult.cs
rename to Sources/SrkToolkit.Web.AspMvc5/JsonNetResult.cs
index 6c24f8c..fba92e6 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/JsonNetResult.cs
+++ b/Sources/SrkToolkit.Web.AspMvc5/JsonNetResult.cs
@@ -16,7 +16,6 @@
namespace SrkToolkit.Web
{
- using Microsoft.AspNetCore.Mvc;
using System;
using System.Diagnostics;
using System.Runtime.Serialization.Json;
@@ -60,7 +59,7 @@ public JsonNetResult()
///
/// The JSON serializer.
///
- public static Action
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/Mvc/DecimalModelBinder.cs b/Sources/SrkToolkit.Web.AspNetCore2/Mvc/DecimalModelBinder.cs
index ecdee11..c9c6630 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/Mvc/DecimalModelBinder.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/Mvc/DecimalModelBinder.cs
@@ -16,13 +16,21 @@
namespace SrkToolkit.Web.Mvc
{
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Mvc.ModelBinding;
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Mvc;
+ using Microsoft.AspNetCore.Mvc;
+ using Microsoft.AspNetCore.Mvc.ModelBinding;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
- using System.Web.Mvc;
using System.Globalization;
using System.Reflection;
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkControllerExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkControllerExtensions.cs
index aa89ae9..e2971ca 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkControllerExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkControllerExtensions.cs
@@ -16,8 +16,17 @@
namespace SrkToolkit.Web
{
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Routing;
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Mvc;
+ using Microsoft.AspNetCore.Routing;
+#endif
+
+#if ASPMVC
+ using System.Web.Mvc;
+ using System.Web.Caching;
+ using System.Web.Routing;
+#endif
+
using SrkToolkit.Web.Models;
using SrkToolkit.Web.Open;
using System;
@@ -52,7 +61,8 @@ public static NavigationLine NavigationLine(this Controller ctrl)
return line;
}
-/*
+
+#if ASPMVC
///
/// Gets an item from the HTTP cache.
///
@@ -63,7 +73,7 @@ public static NavigationLine NavigationLine(this Controller ctrl)
/// The build data.
/// The identifier.
///
- [Obsolete("Under devleopment")]
+ [Obsolete("Under development")]
public static T GetFromCache(this Controller ctrl, TimeSpan duration, CacheItemPriority priority, Func buildData, string id)
where T : class
{
@@ -88,7 +98,7 @@ public static T GetFromCache(this Controller ctrl, TimeSpan duration, CacheIt
/// The priority.
/// The build data.
///
- [Obsolete("Under devleopment")]
+ [Obsolete("Under development")]
public static T GetFromCache(this Controller ctrl, TimeSpan duration, CacheItemPriority priority, Func buildData)
where T : class
{
@@ -103,7 +113,7 @@ public static T GetFromCache(this Controller ctrl, TimeSpan duration, CacheIt
return value;
}
-*//*
+
///
/// Clears an item from the HTTP cache.
///
@@ -111,7 +121,7 @@ public static T GetFromCache(this Controller ctrl, TimeSpan duration, CacheIt
/// The controller.
/// The identifier.
///
- [Obsolete("Under devleopment")]
+ [Obsolete("Under development")]
public static T ClearFromCache(this Controller ctrl, string id)
where T : class
{
@@ -133,7 +143,7 @@ public static T ClearFromCache(this Controller ctrl, string id)
///
/// The control.
///
- [Obsolete("Under devleopment")]
+ [Obsolete("Under development")]
public static T ClearFromCache(this Controller ctrl)
where T : class
{
@@ -148,7 +158,7 @@ public static T ClearFromCache(this Controller ctrl)
return null;
}
-*/
+#endif
///
/// Gets a action result that will redirect the user to the specified local path. Fallbacks to a second path. Then fallbacks to /Home/Index
///
@@ -177,7 +187,7 @@ public static ActionResult RedirectToLocal(this Controller controller, string lo
return new RedirectToRouteResult(values);
}
}
-/*
+#if ASPMVC
///
/// Gets the first valid local URL from the method arguments.
///
@@ -216,7 +226,8 @@ public static string GetAnyLocalUrl(this Controller controller, string url1, boo
return null;
}
-*/
+#endif
+
///
/// Helps attach descriptors to a page in order to generate meta/link tags.
///
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpContextExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpContextExtensions.cs
index 8d479c2..50407cb 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpContextExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpContextExtensions.cs
@@ -16,7 +16,18 @@
namespace SrkToolkit.Web
{
- using Microsoft.AspNetCore.Http;
+
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Http;
+ using Microsoft.AspNetCore.Mvc;
+ using Microsoft.AspNetCore.Routing;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -41,7 +52,8 @@ public static string GetUserIdentityName(this HttpContext httpContext)
return httpContext.User != null && httpContext.User.Identity != null ? httpContext.User.Identity.Name.NullIfEmptyOrWhitespace() : null;
}
-/*
+
+#if ASPMVC
///
/// Fast access to HttpContext.User.Identity.Name.
///
@@ -55,7 +67,7 @@ public static string GetUserIdentityName(this HttpContextBase httpContext)
return httpContext.User != null && httpContext.User.Identity != null ? httpContext.User.Identity.Name.NullIfEmptyOrWhitespace() : null;
}
-*//*
+
///
/// Sets the timezone for displays of dates and times.
///
@@ -72,7 +84,7 @@ public static HttpContextBase SetTimezone(this HttpContextBase http, string time
SrkHttpContextExtensions.SetTimezone(http, TimeZoneInfo.FindSystemTimeZoneById(timeZoneName));
return http;
}
-*//*
+
///
/// Sets the timezone for displays of dates and times.
///
@@ -88,7 +100,8 @@ public static HttpContextBase SetTimezone(this HttpContextBase http, TimeZoneInf
http.Items["Timezone"] = timeZone;
return http;
}
-*/
+#endif
+
///
/// Sets the timezone for displays of dates and times.
///
@@ -121,7 +134,8 @@ public static HttpContext SetTimezone(this HttpContext http, TimeZoneInfo timeZo
http.Items["Timezone"] = timeZone;
return http;
}
-/*
+
+#if ASPMVC
///
/// Gets the timezone for displays of dates and times.
///
@@ -135,7 +149,8 @@ public static TimeZoneInfo GetTimezone(this HttpContextBase http)
return (TimeZoneInfo)http.Items["Timezone"] ?? TimeZoneInfo.Utc;
}
-*/
+#endif
+
///
/// Gets the timezone for displays of dates and times.
///
@@ -149,7 +164,8 @@ public static TimeZoneInfo GetTimezone(this HttpContext http)
return (TimeZoneInfo)http.Items["Timezone"] ?? TimeZoneInfo.Utc;
}
-/*
+
+#if ASPMVC
///
/// Sets the culture.
///
@@ -173,7 +189,8 @@ public static HttpContextBase SetCulture(this HttpContextBase http, string cultu
http.Items["Culture"] = cultureInfo;
return http;
}
-*/
+#endif
+
///
/// Sets the culture.
///
@@ -197,7 +214,8 @@ public static HttpContext SetCulture(this HttpContext http, string culture)
http.Items["Culture"] = cultureInfo;
return http;
}
-/*
+
+#if ASPMVC
///
/// Sets the culture.
///
@@ -213,7 +231,8 @@ public static HttpContextBase SetCulture(this HttpContextBase http, CultureInfo
http.Items["Culture"] = culture;
return http;
}
-*/
+#endif
+
///
/// Sets the culture.
///
@@ -229,7 +248,8 @@ public static HttpContext SetCulture(this HttpContext http, CultureInfo culture)
http.Items["Culture"] = culture;
return http;
}
-/*
+
+#if ASPMVC
///
/// Gets the current culture.
///
@@ -243,7 +263,8 @@ public static CultureInfo GetCulture(this HttpContextBase http)
return (CultureInfo)http.Items["Culture"] ?? CultureInfo.CurrentCulture;
}
-*/
+#endif
+
///
/// Gets the current culture.
///
@@ -257,7 +278,8 @@ public static CultureInfo GetCulture(this HttpContext http)
return (CultureInfo)http.Items["Culture"] ?? CultureInfo.CurrentCulture;
}
-/*
+
+#if ASPMVC
///
/// Sets the UICulture.
///
@@ -281,7 +303,8 @@ public static HttpContextBase SetUICulture(this HttpContextBase http, string uIC
http.Items["UICulture"] = cultureInfo;
return http;
}
-*/
+#endif
+
///
/// Sets the UICulture.
///
@@ -305,7 +328,8 @@ public static HttpContext SetUICulture(this HttpContext http, string uICulture)
http.Items["UICulture"] = cultureInfo;
return http;
}
-/*
+
+#if ASPMVC
///
/// Sets the UICulture.
///
@@ -321,7 +345,8 @@ public static HttpContextBase SetUICulture(this HttpContextBase http, CultureInf
http.Items["UICulture"] = uICulture;
return http;
}
-*/
+#endif
+
///
/// Sets the UICulture.
///
@@ -337,7 +362,8 @@ public static HttpContext SetUICulture(this HttpContext http, CultureInfo uICult
http.Items["UICulture"] = uICulture;
return http;
}
-/*
+
+#if ASPMVC
///
/// Gets the current UICulture.
///
@@ -351,7 +377,8 @@ public static CultureInfo GetUICulture(this HttpContextBase http)
return (CultureInfo)http.Items["UICulture"] ?? CultureInfo.CurrentUICulture;
}
-*/
+#endif
+
///
/// Gets the current UICulture.
///
@@ -365,7 +392,8 @@ public static CultureInfo GetUICulture(this HttpContext http)
return (CultureInfo)http.Items["UICulture"] ?? CultureInfo.CurrentUICulture;
}
-/*
+
+#if ASPMVC
///
/// Sets the date and time formats.
///
@@ -379,7 +407,7 @@ public static CultureInfo GetUICulture(this HttpContext http)
/// The short time format for Html.DisplayShortTime(DateTime).
/// The short timespan format for Html.DisplayShortTime(TimeSpan).
/// httpContext
- public static void SetDateTimeFormats(this HttpContext httpContext, string dateFormat = null, string dateTzFormat = null, string timeFormat = null, string timeTzFormat = null, string timespanFormat = null, string dateTimeFormat = null, string shortTimeFormat = null, string shortTimespanFormat = null)
+ public static void SetDateTimeFormats(this HttpContextBase httpContext, string dateFormat = null, string dateTzFormat = null, string timeFormat = null, string timeTzFormat = null, string timespanFormat = null, string dateTimeFormat = null, string shortTimeFormat = null, string shortTimespanFormat = null)
{
if (httpContext == null)
throw new ArgumentNullException("httpContext");
@@ -438,7 +466,7 @@ public static void SetDateTimeFormats(this HttpContext httpContext, string dateF
httpContext.Items[SrkHtmlExtensions.DefaultDateTimeFormatsKey] = values;
}
-*//*
+
///
/// Gets the date and time formats.
///
@@ -450,11 +478,12 @@ public static string[] GetDateTimeFormats(this HttpContextBase httpContext)
if (httpContext == null)
throw new ArgumentNullException("httpContext");
- var values = (string[])httpContext.Items[System.Web.Mvc.SrkHtmlExtensions.defaultDateTimeFormatsKey]
- ?? System.Web.Mvc.SrkHtmlExtensions.defaultDateTimeFormats.ToArray();
+ var values = (string[])httpContext.Items[System.Web.Mvc.SrkHtmlExtensions.DefaultDateTimeFormatsKey]
+ ?? System.Web.Mvc.SrkHtmlExtensions.DefaultDateTimeFormats.ToArray();
return values;
}
-*/
+#endif
+
}
}
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpRequestExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpRequestExtensions.cs
index ab17355..ca5ea3d 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpRequestExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkHttpRequestExtensions.cs
@@ -1,14 +1,26 @@
namespace SrkToolkit.AspNetCore
{
- using Microsoft.AspNetCore.Http;
+
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Http;
+ using Microsoft.AspNetCore.Mvc;
+ using Microsoft.AspNetCore.Routing;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
+
using System;
using System.Diagnostics;
using System.Linq;
- using System.Net.Http;
public static class SrkHttpRequestExtensions
{
+#if ASPMVCCORE
public static bool PrefersJson(this HttpRequestMessage request)
{
if (request.Headers.Accept.Any())
@@ -24,9 +36,10 @@ public static bool PrefersJson(this HttpRequestMessage request)
return false;
}
-
+#endif
+
+/*
// TODO: support HttpRequest.PrefersJson, but which nuget?
-#if !NETSTANDARD
public static bool PrefersJson(this HttpRequest request)
{
Debug.Assert(request != null, nameof(request) + " != null");
@@ -43,6 +56,7 @@ public static bool PrefersJson(this HttpRequest request)
return false;
}
-#endif
+*/
+
}
}
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkMvcCollectionExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkMvcCollectionExtensions.cs
index 724157e..05e9c2f 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkMvcCollectionExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkMvcCollectionExtensions.cs
@@ -16,7 +16,15 @@
namespace SrkToolkit.Web
{
- using Microsoft.AspNetCore.Mvc.Rendering;
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Mvc.Rendering;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkRequestExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkRequestExtensions.cs
index 0d86b3d..9f96a35 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkRequestExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkRequestExtensions.cs
@@ -16,9 +16,19 @@
namespace SrkToolkit.Web
{
+#if ASPMVCCORE
using Microsoft.AspNetCore.Http;
- using System;
- using System.Collections.Generic;
+ using Microsoft.AspNetCore.Mvc;
+ using Microsoft.AspNetCore.Routing;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
+ using System;
+ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
@@ -41,13 +51,23 @@ public static class SrkRequestExtensions
///
/// true if [is XML HTTP request] [the specified request]; otherwise, false.
///
- public static bool IsXmlHttpRequest(this HttpRequest request)
- {
+ public static bool IsXmlHttpRequest(
+#if ASPMVCCORE
+ this HttpRequest request
+#elif ASPMVC
+ this HttpRequestBase request
+#endif
+ )
+ {
var header = request.Headers["X-Requested-With"];
if (string.IsNullOrEmpty(header))
return false;
- return xhrValues.Any(searchValue => header.Any(value => value.Equals(searchValue, StringComparison.OrdinalIgnoreCase)));
+#if ASPMVCCORE
+ return xhrValues.Any(searchValue => header.Any(value => value.Equals(searchValue, StringComparison.OrdinalIgnoreCase)));
+#elif ASPMVC
+ return xhrValues.Contains(header.ToUpperInvariant());
+#endif
}
///
@@ -55,50 +75,105 @@ public static bool IsXmlHttpRequest(this HttpRequest request)
///
/// The request.
///
- public static bool IsHttpGetRequest(this HttpRequest request)
- {
- return "GET".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
- }
+ public static bool IsHttpGetRequest(
+#if ASPMVCCORE
+ this HttpRequest request
+#elif ASPMVC
+ this HttpRequestBase request
+#endif
+ )
+ {
+
+#if ASPMVCCORE
+ return "GET".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
+#elif ASPMVC
+ return "GET".Equals(request.HttpMethod, StringComparison.OrdinalIgnoreCase);
+#endif
+ }
///
/// Determines whether the HTTP method is POST.
///
/// The request.
///
- public static bool IsHttpPostRequest(this HttpRequest request)
- {
- return "POST".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
- }
+ public static bool IsHttpPostRequest(
+#if ASPMVCCORE
+ this HttpRequest request
+#elif ASPMVC
+ this HttpRequestBase request
+#endif
+ )
+ {
+
+#if ASPMVCCORE
+ return "POST".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
+#elif ASPMVC
+ return "POST".Equals(request.HttpMethod, StringComparison.OrdinalIgnoreCase);
+#endif
+ }
///
/// Determines whether the HTTP method is DELETE.
///
/// The request.
///
- public static bool IsHttpDeleteRequest(this HttpRequest request)
- {
- return "DELETE".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
- }
+ public static bool IsHttpDeleteRequest(
+#if ASPMVCCORE
+ this HttpRequest request
+#elif ASPMVC
+ this HttpRequestBase request
+#endif
+ )
+ {
+
+#if ASPMVCCORE
+ return "DELETE".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
+#elif ASPMVC
+ return "DELETE".Equals(request.HttpMethod, StringComparison.OrdinalIgnoreCase);
+#endif
+ }
///
/// Determines whether the HTTP method is PUT.
///
/// The request.
///
- public static bool IsHttpPutRequest(this HttpRequest request)
- {
- return "PUT".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
- }
+ public static bool IsHttpPutRequest(
+#if ASPMVCCORE
+ this HttpRequest request
+#elif ASPMVC
+ this HttpRequestBase request
+#endif
+ )
+ {
+
+#if ASPMVCCORE
+ return "PUT".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
+#elif ASPMVC
+ return "PUT".Equals(request.HttpMethod, StringComparison.OrdinalIgnoreCase);
+#endif
+ }
///
/// Determines whether the HTTP method is HEAD.
///
/// The request.
///
- public static bool IsHttpHeadRequest(this HttpRequest request)
- {
- return "HEAD".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
- }
+ public static bool IsHttpHeadRequest(
+#if ASPMVCCORE
+ this HttpRequest request
+#elif ASPMVC
+ this HttpRequestBase request
+#endif
+ )
+ {
+
+#if ASPMVCCORE
+ return "HEAD".Equals(request.Method, StringComparison.OrdinalIgnoreCase);
+#elif ASPMVC
+ return "HEAD".Equals(request.HttpMethod, StringComparison.OrdinalIgnoreCase);
+#endif
+ }
///
/// Determines whether the specified URL is local to the request's host.
@@ -106,8 +181,14 @@ public static bool IsHttpHeadRequest(this HttpRequest request)
/// The request.
/// The URL.
///
- public static bool IsUrlLocalToHost(this HttpRequest request, string url)
- {
+ public static bool IsUrlLocalToHost(
+#if ASPMVCCORE
+ this HttpRequest request,
+#elif ASPMVC
+ this HttpRequestBase request,
+#endif
+ string url)
+ {
return IsUrlLocalToHost(url);
}
@@ -127,13 +208,24 @@ private static bool IsUrlLocalToHost(string url)
/// The request.
/// true if the first accept type is JSON; otherwise, false
/// request
- public static bool PrefersJson(this HttpRequest request)
- {
+ public static bool PrefersJson(
+#if ASPMVCCORE
+ this HttpRequest request
+#elif ASPMVC
+ this HttpRequestBase request
+#endif
+ )
+ {
if (request == null)
throw new ArgumentNullException("request");
- return PrefersJson(request.Headers["Accept"]);
- }
+
+#if ASPMVCCORE
+ return PrefersJson(request.Headers["Accept"]);
+#elif ASPMVC
+ return PrefersJson(request.AcceptTypes);
+#endif
+ }
private static bool PrefersJson(string[] acceptTypes)
{
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkTagBuilderExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkTagBuilderExtensions.cs
index eddb62f..8b45ade 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkTagBuilderExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkTagBuilderExtensions.cs
@@ -16,31 +16,42 @@
namespace SrkToolkit.Web
{
- using Microsoft.AspNetCore.Html;
- using Microsoft.AspNetCore.Mvc.Rendering;
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Html;
+ using Microsoft.AspNetCore.Mvc.Rendering;
+ using System.Text.Encodings.Web;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
- using System.Text.Encodings.Web;
///
/// Extension methods for the class.
///
public static class SrkTagBuilderExtensions
{
-/*
+
+#if ASPMVC
///
/// To the MVC HTML string.
///
/// The tag builder.
/// The render mode.
///
- public static HtmlString ToMvcHtmlString(this TagBuilder tagBuilder, TagRenderMode renderMode)
- {
- return new HtmlString(tagBuilder.ToString(renderMode));
- }
-*/
+ public static MvcHtmlString ToMvcHtmlString(this TagBuilder tagBuilder, TagRenderMode renderMode)
+ {
+ return new MvcHtmlString(tagBuilder.ToString(renderMode));
+ }
+#endif
+
+#if ASPMVCCORE
public static HtmlString ToHtmlString(this TagBuilder tag)
{
if (tag == null)
@@ -51,6 +62,7 @@ public static HtmlString ToHtmlString(this TagBuilder tag)
using var writer = new StringWriter();
tag.WriteTo(writer, HtmlEncoder.Default);
return new HtmlString(writer.ToString());
- }
+ }
+#endif
}
}
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkTempDataDictionaryExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkTempDataDictionaryExtensions.cs
index 340f196..60fb905 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkTempDataDictionaryExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkTempDataDictionaryExtensions.cs
@@ -16,7 +16,15 @@
namespace SrkToolkit.Web
{
- using Microsoft.AspNetCore.Mvc.ViewFeatures;
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Mvc.ViewFeatures;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
using SrkToolkit.Web.Models;
using System.Collections.Generic;
@@ -31,8 +39,14 @@ public static class SrkTempDataDictionaryExtensions
/// The temp data.
/// The error message.
/// indicates the message contains HTML markup
- public static void AddError(this ITempDataDictionary tempData, string errorMessage, bool isMarkup = false)
- {
+ public static void AddError(
+#if ASPMVC
+ this TempDataDictionary tempData,
+#elif ASPMVCCORE
+ this ITempDataDictionary tempData,
+#endif
+ string errorMessage, bool isMarkup = false)
+ {
var message = new TempMessage(TempMessageKind.Error, errorMessage, isMarkup);
AddMessage(tempData, message);
@@ -44,8 +58,14 @@ public static void AddError(this ITempDataDictionary tempData, string errorMessa
/// The temp data.
/// The warning message.
/// indicates the message contains HTML markup
- public static void AddWarning(this ITempDataDictionary tempData, string warningMessage, bool isMarkup = false)
- {
+ public static void AddWarning(
+#if ASPMVC
+ this TempDataDictionary tempData,
+#elif ASPMVCCORE
+ this ITempDataDictionary tempData,
+#endif
+ string warningMessage, bool isMarkup = false)
+ {
var message = new TempMessage(TempMessageKind.Warning, warningMessage, isMarkup);
AddMessage(tempData, message);
@@ -57,8 +77,14 @@ public static void AddWarning(this ITempDataDictionary tempData, string warningM
/// The temp data.
/// The info message.
/// indicates the message contains HTML markup
- public static void AddInfo(this ITempDataDictionary tempData, string infoMessage, bool isMarkup = false)
- {
+ public static void AddInfo(
+#if ASPMVC
+ this TempDataDictionary tempData,
+#elif ASPMVCCORE
+ this ITempDataDictionary tempData,
+#endif
+ string infoMessage, bool isMarkup = false)
+ {
var message = new TempMessage(TempMessageKind.Information, infoMessage, isMarkup);
AddMessage(tempData, message);
@@ -70,8 +96,14 @@ public static void AddInfo(this ITempDataDictionary tempData, string infoMessage
/// The temp data.
/// The info message.
/// indicates the message contains HTML markup
- public static void AddConfirmation(this ITempDataDictionary tempData, string message, bool isMarkup = false)
- {
+ public static void AddConfirmation(
+#if ASPMVC
+ this TempDataDictionary tempData,
+#elif ASPMVCCORE
+ this ITempDataDictionary tempData,
+#endif
+ string message, bool isMarkup = false)
+ {
var msg = new TempMessage(TempMessageKind.Confirmation, message, isMarkup);
AddMessage(tempData, msg);
@@ -82,8 +114,14 @@ public static void AddConfirmation(this ITempDataDictionary tempData, string mes
///
/// The temp data.
///
- public static IList GetAll(this ITempDataDictionary tempData)
- {
+ public static IList GetAll(
+#if ASPMVC
+ this TempDataDictionary tempData
+#elif ASPMVCCORE
+ this ITempDataDictionary tempData
+#endif
+ )
+ {
var list = new List();
if (tempData.ContainsKey(TempMessage.TempDataKey))
@@ -96,8 +134,14 @@ public static IList GetAll(this ITempDataDictionary tempData)
return list;
}
- private static void AddMessage(ITempDataDictionary tempData, TempMessage message)
- {
+ private static void AddMessage(
+#if ASPMVC
+ this TempDataDictionary tempData,
+#elif ASPMVCCORE
+ this ITempDataDictionary tempData,
+#endif
+ TempMessage message)
+ {
IList list = null;
if (tempData.ContainsKey(TempMessage.TempDataKey))
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkToolkit.Web.AspNetCore2.csproj b/Sources/SrkToolkit.Web.AspNetCore2/SrkToolkit.Web.AspNetCore2.csproj
index b9a2fa4..955b586 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkToolkit.Web.AspNetCore2.csproj
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkToolkit.Web.AspNetCore2.csproj
@@ -3,7 +3,7 @@
netstandard2.0
enable
- default
+ 10
SrkToolkit.Web
true
2.0.147-preview2
@@ -91,7 +91,6 @@
-
@@ -124,10 +123,6 @@
-
-
-
-
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkUrlHelperExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkUrlHelperExtensions.cs
index 090cc21..df8166b 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkUrlHelperExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkUrlHelperExtensions.cs
@@ -16,8 +16,17 @@
namespace SrkToolkit.Web
{
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Mvc.Routing;
+ using Microsoft.AspNetCore.Mvc.Routing;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
using System;
using System.Collections.Generic;
using System.Linq;
@@ -102,8 +111,14 @@ public static Uri ResetQueryString(this Uri uri, params string[] keysAndValues)
/// the modified URL
///
/// keysAndValues must be contain pairs of key and value;keysAndValues
- public static string ResetQueryString(this IUrlHelper helper, string url, params string[] keysAndValues)
- {
+ public static string ResetQueryString(
+#if ASPMVC
+ this UrlHelper helper,
+#elif ASPMVCCORE
+ this IUrlHelper helper,
+#endif
+ string url, params string[] keysAndValues)
+ {
return SetQueryString(url, true, keysAndValues);
}
@@ -144,8 +159,14 @@ public static Uri SetQueryString(this Uri uri, params string[] keysAndValues)
/// the modified URL
///
/// keysAndValues must be contain pairs of key and value;keysAndValues
- public static string SetQueryString(this IUrlHelper helper, string url, params string[] keysAndValues)
- {
+ public static string SetQueryString(
+#if ASPMVC
+ this UrlHelper helper,
+#elif ASPMVCCORE
+ this IUrlHelper helper,
+#endif
+ string url, params string[] keysAndValues)
+ {
return SetQueryString(url, keysAndValues);
}
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/SrkViewExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/SrkViewExtensions.cs
index 1e8075c..950c4d6 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/SrkViewExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/SrkViewExtensions.cs
@@ -16,7 +16,17 @@
namespace SrkToolkit.Web
{
- using Microsoft.AspNetCore.Mvc.Razor;
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Http;
+ using Microsoft.AspNetCore.Mvc;
+ using Microsoft.AspNetCore.Mvc.Razor;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
using SrkToolkit.Web.Models;
using System;
using System.Collections.Generic;
@@ -33,8 +43,14 @@ public static class SrkViewExtensions
///
///
///
- public static IList TempMessages(this IRazorPage view)
- {
+ public static IList TempMessages(
+#if ASPMVC
+ this WebViewPage view
+#elif ASPMVCCORE
+ this IRazorPage view
+#endif
+ )
+ {
if (view == null)
throw new ArgumentNullException(nameof(view));
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/WebDependencies.cs b/Sources/SrkToolkit.Web.AspNetCore2/WebDependencies.cs
index 5d1b28c..97a1895 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/WebDependencies.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/WebDependencies.cs
@@ -16,21 +16,33 @@
namespace SrkToolkit.Web
{
- using Microsoft.AspNetCore.Html;
+#if ASPMVCCORE
+ using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc.Rendering;
- using System;
- using System.Collections.Generic;
+ using Microsoft.AspNetCore.Mvc.Rendering;
+ using System.Text.Encodings.Web;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+ using System.Web.Hosting;
+#endif
+
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using System.Linq;
using System.Text;
- using System.Text.Encodings.Web;
///
/// Manages web dependencies such as scripts and styles.
///
public class WebDependencies
{
+#if ASPMVCCORE
private readonly PathString requestPathBase;
+#endif
protected Dictionary> includes;
///
@@ -40,6 +52,7 @@ public WebDependencies()
{
}
+#if ASPMVCCORE
public WebDependencies(PathString requestPathBase)
{
this.requestPathBase = requestPathBase;
@@ -50,6 +63,13 @@ protected string ApplicationVirtualPath
get { return this.requestPathBase.HasValue ? this.requestPathBase.ToString() : "/"; }
////set { this.requestPathBase = new PathString(value); }
}
+#endif
+#if ASPMVC
+ protected string ApplicationVirtualPath
+ {
+ get { return HostingEnvironment.ApplicationVirtualPath; }
+ }
+#endif
///
/// Renders the specified dependency.
@@ -70,10 +90,18 @@ public HtmlString Render(WebDependency value)
RenderDependency(value.Files[i], sb);
}
- return new HtmlString(sb.ToString());
+#if ASPMVCCORE
+ return new HtmlString(sb.ToString());
+#elif ASPMVC
+ return MvcHtmlString.Create(sb.ToString());
+#endif
}
- return HtmlString.Empty;
+#if ASPMVCCORE
+ return HtmlString.Empty;
+#elif ASPMVC
+ return MvcHtmlString.Empty;
+#endif
}
///
@@ -200,8 +228,12 @@ protected void RenderDependency(WebDependencyFile value, StringWriter sb)
tag.MergeAttributes(value.Attributes);
}
+#if ASPMVCCORE
tag.WriteTo(sb, HtmlEncoder.Default);
sb.WriteLine();
+#elif ASPMVC
+ sb.WriteLine(tag.ToString(TagRenderMode.Normal));
+#endif
break;
case WebDependencyFileType.Css:
@@ -229,9 +261,14 @@ protected void RenderDependency(WebDependencyFile value, StringWriter sb)
tag.MergeAttributes(value.Attributes);
}
+#if ASPMVCCORE
tag.TagRenderMode = TagRenderMode.SelfClosing;
tag.WriteTo(sb, HtmlEncoder.Default);
sb.WriteLine();
+#elif ASPMVC
+ sb.WriteLine(tag.ToString(TagRenderMode.SelfClosing));
+#endif
+ sb.WriteLine();
break;
default:
diff --git a/Sources/SrkToolkit.Web.AspNetCore2/WebDependenciesExtensions.cs b/Sources/SrkToolkit.Web.AspNetCore2/WebDependenciesExtensions.cs
index 76bcfac..35a2ffd 100644
--- a/Sources/SrkToolkit.Web.AspNetCore2/WebDependenciesExtensions.cs
+++ b/Sources/SrkToolkit.Web.AspNetCore2/WebDependenciesExtensions.cs
@@ -16,8 +16,16 @@
namespace SrkToolkit.Web
{
+#if ASPMVCCORE
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Razor;
+#endif
+
+#if ASPMVC
+ using System.Web;
+ using System.Web.Mvc;
+#endif
+
using System;
using System.Collections.Generic;
using System.Linq;
@@ -34,7 +42,13 @@ public static class WebDependenciesExtensions
/// The view.
///
/// view
- public static WebDependencies WebDependencies(this IRazorPage view)
+ public static WebDependencies WebDependencies(
+#if ASPMVC
+ this WebViewPage view
+#elif ASPMVCCORE
+ this IRazorPage view
+#endif
+ )
{
if (view == null)
throw new ArgumentNullException("view");
@@ -47,7 +61,11 @@ public static WebDependencies WebDependencies(this IRazorPage view)
if (obj == null)
{
+#if ASPMVC
+ obj = new WebDependencies();
+#elif ASPMVCCORE
obj = new WebDependencies(view.ViewContext.HttpContext.Request.PathBase);
+#endif
view.ViewContext.ViewData["WebDependencies"] = obj;
if (view.ViewContext.HttpContext != null)
view.ViewContext.HttpContext.Items["WebDependencies"] = obj;
@@ -75,7 +93,11 @@ public static WebDependencies WebDependencies(this Controller controller)
if (obj == null)
{
+#if ASPMVC
+ obj = new WebDependencies();
+#elif ASPMVCCORE
obj = new WebDependencies(controller.Request.PathBase);
+#endif
controller.ViewData["WebDependencies"] = obj;
if (controller.HttpContext != null)
controller.HttpContext.Items["WebDependencies"] = obj;