0

I need to pass the data from view to controller in an mvc project.

I've seen many examples with passing to controller using Form and having a submit button.

Actually I have @foreach to populate data like a grid in the razor view.The first field is a id, which is a link to the respective edit page to edit the fields corresponding to that id. i need to get the clicked id to use it in the controller to display the corresponding edit page. Here there is no need of submit buttons.

Also i dont want to show the id in querystring, as the id should be secured.

How can i do that ? Please help

Thanks,

3 Answers 3

2

The best way to get data to the controller in MVC without a submit is to use JQuery ajax to send the request and handle the response in JavaScript. You can use a POST request so that the data is not in the query string but that does not make it any more secure. The only way to secure the data in an HTTP request is to use HTTPS/SSL.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to create a custom Routing in you globle.asax file like this

routes.MapRoute(
                "Check", // Route nameRegister
                "Artical", // URL with parameters
                new { controller = "Artical", action = "Index", id = UrlParameter.Optional }  
            );

i think this will help you...

Comments

0

I'm not sure if you can get away without passing an Id to the Edit page to edit that specific data. You could send it out to a session or cache object. That's all I can think of off the top of my head. Using the Id is not really risking security I think, but then again, everywhere I've done any kind of edit page I've always passed the Id and never had an issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.