Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Create Custome class of AuthorizeAttribute implementation issue in mvc core

$
0
0

Hi,
I create a class which implement AuthorizeAttribute Interface with override method HandleUnauthorizedRequest in mvc core.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using IdentityTest.DBModel;

namespace IdentityTest.CustomFolder
{
public class CustomErrorTexelMobile: AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
using (MobileEntities db = new MobileEntities())
{
var res = db.SelfServeAdmins.FirstOrDefault(sid => sid.MobileSignOnEnabled == true);
if (res == null)
{
filterContext.Result = new RedirectToRouteResult(new
RouteValueDictionary(new {controller = "PermissionError", action = "AccessDenied"}));
}
}
}
}
}

Compile Time error: Error CS7069 Reference to type 'RouteValueDictionary' claims it is defined in 'System.Web', but it could not be found

How can to slove this issue. Which namespace necessary for MVC Core against This issue.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>