How can I restrict access to a view only to two specific users each time in MVC?

How can I restrict access to a view only to two specific users each time in MVC?

Content Index :

How can I restrict access to a view only to two specific users each time in MVC?
Tag : asp.net-mvc , By : deanschang
Date : November 23 2020, 01:01 AM

wish helps you You can check inside Action user's id and check if is equal to FirstPartyId or SecondPartyId
public ActionResult Ticket(int tid)
    var userId = User.Identity.GetUserId();
    var ticket = db.Tickets.Where(t => t.TicketID == tid).FirstOrDefault();
    // check if null
    if(ticket == null)
         return HttpNotFound();
    if(userId != ticket.FirstPartyId || userId != SecondPartyId)
          return HttpNotFound(); // return 404 or redirect here
    return View(ticket);

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Restrict page view access to specific users/customers

Tag : django , By : Kim
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Certainly not a new question I think, but here it goes: , Add a field to your invoice model called user:
user = models.ForeignKey(User, related_name="invoices")
invoice = CustomerInvoice.objects.get(pk=object_id, user=request.user)

How to restrict write access to users which are declared under a specific node in the Real Time Database

Tag : android , By : user126922
Date : March 29 2020, 07:55 AM
I hope this helps you . There is no automatic link between the existence of your user in the Authentication panel and the user's data under the Users node, in your DB. So, like you mention in your post, if you delete the user node in the DB, he/she will still be able to authenticate.
Therefore you have to secure your database with a dedicated security rule (Consider it as the authorization part of the whole authentication/authorization mechanism).
  "rules": {
    "comments": {
      ".write": "auth != null && root.child('Users').hasChild(auth.uid)"
      ".read": ...

Restrict API gateway access to specific IAM users

Tag : amazon-web-services , By : Heals1ic
Date : March 29 2020, 07:55 AM
I hope this helps you . So I found the answer here.
There are 2 parts to this:

How to restrict access for my users to a specific IP?

Tag : node.js , By : James Cary
Date : March 29 2020, 07:55 AM
I wish did fix the issue. After a quick google search I found this:
You can get the connected client's IP with this for example:
var ip = req.header('x-forwarded-for') || req.connection.remoteAddress;

How do I restrict specific trac/svn users to access specific folders/trunk of SVN?

Tag : svn , By : Frank Bradley
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How to get a list of sibling pages in Kentico
  • Ninject dependency injection: Read bindings from config?
  • ASP.NET MVC database connection using a form
  • IIS7.5 max-age issue(asp.net mvc output cache)
  • Why i can not send parameter to controller with ajax?
  • mvc linq controller view error
  • Creating Custom Authorization Attribute with MVC
  • How does the model binder figure out which user input to bind?
  • DecimalDynamicDisplayFormat constant expression error
  • Property injection upon initializing object manually
  • how to force partial view to render proper url
  • Identity can't connect to remote DB, keep connecting to local DB
  • How to use c# inside mvc razor pages
  • Reasons not to increase maxQueryStringLength?
  • asp.net mvc exclude an action from search engine crawling
  • Best Way to reuse code inside my Controller action method
  • BEM and asp.net mvc
  • RazorPDF save pdf file to server directory in MVC4
  • Controller Unit Testing with model validation
  • How to bind input field to editfor model MVC
  • WebGrid all buttons submits the form
  • Kendo UI Grid data bind to two table DB
  • How to modify CRUD operations with Entity Framework in .NET MVC application
  • ModelBinding Issue with a Struct
  • Web Api with & causing an error
  • dropdownlistfor selected value with viewdata
  • MVC 4 dropdownlist in edit form doesnt give the correct value after edit command from grid
  • Trying to move asp.net identity tables to my database
  • issue in adding elements into a list in mvc
  • IActionFilter class can only find physical attributes, not ones added in GlobalFilters config
  • ASP.NET MVC Bug with Model Binding: "Specified cast is not valid" when no data provided for dictionary
  • How to host ASP.NET MVC app on IIS10 win10
  • Get mongodb subDocument
  • SimpleMembershipProvider specify to use hash SHA512, something went wrong
  • How to bind a WebGrid in a PartialView, which is in JQueryUI ModalPopup
  • MVC Membership.UpdateUser(u); Specified method is not supported
  • How to reuse class in models without using validation for all of them
  • Null property in object recovered by EF
  • How to set routing to have some controller actions handled by angular
  • ads while debugging mvc website
  • Use partial views for custom MVC html controls
  • Does editing a Web.config file trigger an overlapping recycle or a start+stop of the application pool?
  • Refreshing my DataTable model and view every few seconds
  • Razor TextBoxFor name and value
  • Session and user authentication using ASP Identity
  • MVC: Should we have any if else OR other logical statement in View?
  • ASP.NET Core Capturing POST data
  • How can i delete multi selected records using checkbox in Kendo Grid?
  • 404.15 not found MVC4 RazorJS
  • Can't seem to get MvcSiteMapProvider to work with routes that have route values
  • ASP.NET Identity and Claims
  • Rejecting an otherwise successful ws-federation login in a CookieAuthenticationProvider()
  • Is it possible to run a java script in a partial view in MVC 5?
  • Passing selected value from the radio buttons to the controller in MVC
  • TFS:The "Microsoft.Reporting.RdlCompile" task could not be loaded from the assembly Microsoft.ReportViewer.Web
  • Uploaded Image not a Display in my Grid View
  • Bind viewmodel to partial view
  • ASP.NET MVC 4 Forms Birthday box
  • Client side validation doesn't work for the dropdown
  • How to set first checkbox checked in mvc
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com