This question about asp.net mvc project, and i'am using html for client side,I don't understand why this is a C# question, or why it is even under VS.NET General Discussion. Is this for WebForms? MVC? Or is this just a vanilla HTML question?
data-customeID
in the CSHTML in the first place?id
attribute?data-customeID
attributes.data-customeID
so that it is opaque to the user. The can see it but doesn't make sense to them readily.I'll try to search about RazorViewEngine to solve my issue for the first, thank you for the solutionI see. Hopefully one of the admins will move this topic under ASP.NET MVC to make it clearer for future readers.
Anyway, why is the attributedata-customeID
in the CSHTML in the first place?
Is there something that client side that needs it? If it is needed client side, then what will happen to your client side JavaScript if it can't find that attribute?
If it only needed server side, why can't the service side code just use theid
attribute?
Anyway, just doing a brain dump of what comes to mind about how I would deal with this issue if I were in your shoes:
- Use my own custom RazorViewEngine where my renderer will strip away the
data-customeID
attributes.- Just encrypt the value in
data-customeID
so that it is opaque to the user. The can see it but doesn't make sense to them readily.
thank you for the explanation before, but for this section "If we could all hide certain elements from the DOM, none of us would be browsing the internet any more, due to security reasons. " I don't understant what you meanYou can't do that. If there is something secret which the rendering browser engine is not meant to render, then you should not be including it in your model. Simple as that. If such values need to be secret, then they should be stored in your database or on a server side code file instead. If we could all hide certain elements from the DOM, none of us would be browsing the internet any more, due to security reasons.
we need this value as parameter to using in another controllerWhat was posted by Skydiver is not the solution, its a technique to disguise the problem. As I already told you, if you have values being rendered to the client side, then you need to change your model to undo that. Prevention is the solution.
Let me put it this way. Why do you have values being shown to the DOM if they are not meant to be there?
yeah i knew that we have to pass information / data to Model, but that information we got from view.cshtml (data-customeID)So you mean to tell me the controller actually goes and parses the .CSHTML of the view? That is a broken implementation. That is beyond broken. That is a complete misuse of the MVC pattern. You need to pass that information around in the model, not in the view.
we using model to access database, after we got the data from database, we parse it to the controller and return it to the view.Then your model as a whole is broken and needs to be rewritten. Completely rewritten.
Are you going to pay me for this work?maybe you can give some of good example, so i can finish my issue.