Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Notes on converting Roadkill wiki (MVC 3/4) to .net core (MVC 6)
  • RedirectToRouteResult is now RedirectToActionResult, with an ActionName property

  • No System.Runtime.Caching - replace it with IMemoryCache (Microsoft.Extensions.Caching.Memory)

  • typeof(x).Assembly is now typeof(x).GetTypeInfo().Assembly

  • MongoCollection has changed

  • StringComparison.InvariantCultureIgnoreCase is gone, easy replacement

  • Configuration + Sections are totally different

  • HttpContext and HttpRequest etc. now found in Microsoft.AspNetCore.Http.Abstractions - Microsoft.AspNetCore.Http.HttpRequest

  • Request.RequestUri is now various new properties, for example Request.Host (a HostString)

  • WebActivatorEx?

  • DependencyResolver?

  • System.Net.Mail - Mailkit instead

  • MvcHtmlString/HtmlString - Microsoft.AspNetCore.Html.Abstractions

    • ToHtmlString() is now .Value
  • HtmlHelper -> IHtmlHelper in Microsoft.AspNetCore.Mvc.ViewFeatures package

    • this return IHtmlContent not HtmlString
    • Use StringHtmlcontent for this
    • HtmlHelper still exists
  • Encoding.Default is gone. Use UTF8 or Unicode

  • htmlhelper.ViewContext.Controller is gone, can't find a way around it.

  • I replaced UrlHelper with IUrlHelper

  • HttpResponse (Microsoft.AspNetCore.Http) has no Cache property anymore

  • Transferring models between actions (preserving ViewData)- no longer seems to work using an Attribute?

  • JsonRequestBehavior.AllowGet is gone

  • CacheContentType attribute is gone

  • OnActionExecuting is now public

  • Localization new technique -

    • services.AddLocalization(options => options.ResourcesPath = "Resources");
  • [ValidateInput] and request validation is gone -

  • [HandleError] is gone

  • Json(obj, JsonRequestBehavior.AllowGet) - JsonRequestBehavior.AllowGet is gone

  • HttpStatusCodeResult is now StatusCodeResult

  • return Javascript() is gone, use Content("js here", "text/javascript")

  • HttpUtility is now System.Net.WebUtility

  • Request.QueryString["Key"] is now Request.Query:

if (Request.Query.ContainsKey("ReturnUrl"))
  StringValues values;
  if (Request.Query.TryGetValue("ReturnUrl", out values))
    string firstValue = values[0].ToLower();

    if (firstValue.Contains("/filemanager/select") || firstValue.Contains("/help"))
      return View("BlankLogin");
var urlHelperFactory = _httpContext.RequestServices.GetService<IUrlHelperFactory>();
var actionAccessor = _httpContext.RequestServices.GetService<IActionContextAccessor>();
IUrlHelper urlHelper = urlHelperFactory.GetUrlHelper(actionAccessor.ActionContext);

This comment has been minimized.

Copy link

Workshop2 commented May 27, 2017


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.