0

In asp.net mvc 4 project, there are a lot of pages that have create-update-insert-delete events. I try to build a demo user. But I don't want to update my code in every button click. If this demo user logins then only can select. Must not CRUD.

How can i do with minimum code? Thanks.

H Bıyıkcı
  • 25
  • 1
  • 8

1 Answers1

0

Look into creating a custom [Authorize] Attribute.

You would put that on each controller at the top and the attribute code will run for each controller action checking if the current user should have access to it.

[MSDN for background]

https://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute%28v=vs.118%29.aspx

[Stackoverflow answer]

ASP.NET MVC 4 Custom Authorize Attribute with Permission Codes (without roles)

Community
  • 1
  • 1
krilovich
  • 3,475
  • 1
  • 23
  • 33
  • I thougt that. I will create a user in database which have only **select** authority. If demo user logins then use this connectionstring. **Changing connectionString dynamically** is logical and possible? Thanks. – H Bıyıkcı Feb 17 '15 at 07:44