1

My ASP.NET Core application uses VB.net library that needs to know privileges of the current user. It used My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) call before, but in asp.net core it comes up with the following exception:

System.TypeLoadException: 'Could not load type 'Microsoft.VisualBasic.ApplicationServices.User' from assembly 'Microsoft.VisualBasic, Version=10.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.'

I also tried to use System.Web.Security.Roles.IsUserInRole("Administrators")

But this one will not load system.web

Is there an alternative way to do it?

AnKing
  • 1,994
  • 6
  • 31
  • 54
  • I think you will want to explore the [Authorize] attribute on one of your Controllers. See other SO question with that topic. – No Refunds No Returns Dec 06 '18 at 19:19
  • @NoRefundsNoReturns this is happening not within the controller. But within the library controller calls – AnKing Dec 06 '18 at 19:43
  • You might have a problem until [.NET Core 3 is released](https://blogs.msdn.microsoft.com/vbteam/2018/11/12/visual-basic-in-net-core-3-0/), You can try [binding redirects for .net Core](https://stackoverflow.com/a/46120907/3419825) – Balah Dec 06 '18 at 20:26

0 Answers0