.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

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,199 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,292 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,581 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,846 Reputation points
    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 26,141 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