.Net 5 and Web MVC page question

Ahmed Bahgat 1 Reputation point
2021-09-22T12:40:50.947+00:00

Hello Experts

I am all new to this and real stumbled with an issue that I am not even sure would be achievable or not

I have a Web page designed with what is mentioned in the title, it is only one page that shows a few input boxes to fill in, I need to set the value of one of those boxes and lock it so the user cannot change it, let's assume the url for this page is

https://aaa.azurewebsites.net/Registration/Create

My idea is to pass the value of that input box in the url as the {id?], so the url will become something like

https://aaa.azurewebsites.net/Registration/Create?myvalue

So how can I set the input box value to myvalue in the url and then lock it so the user cannot change

Is that possible? and if so how can I do that please. this is really important for covid-19 testing which is currently spreading widely in NSW Australia and I need to track the test registrations via that input box

Cheers

Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | VB
Developer technologies | C#
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2021-09-22T14:39:36.167+00:00

    If you don’t want your site hackable, you should encrypt the hidden value. If you want to display the value also, use a styled span or read only input.


  2. AgaveJoe 30,126 Reputation points
    2021-09-22T20:06:57.08+00:00

    The URL you've shared is incorrect. Querystring parameters are located after the "?" and consist of a name and a value.

    https://crsweb.azurewebsites.net?id=1  
    

    MVC has the concept of a route parameter where the parameter is part of the URL which matches a pattern. The default pattern is an id at the end of the URL.

    https://crsweb.azurewebsites.net/controller/action/1  
    

    Your best option is to go through a beginning level tutorial which covers these fundamentals.

    Get started with ASP.NET Core MVC
    Routing in ASP.NET Core


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.