Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

347
Views
Is it good practice to use razor pages directives inside javascript <script> tags to pass model property values?

I'm developing a web app using asp.net core MVC and I've found my self using razor pages directives to pass model property values to javascript for further manipulation of the page. Is this ok? Should I worry of security concerns? If so, could some one explain?

Thanks in advance for any clarification.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It is okay to pass data in javascript for manipulation in your Razor pages. But if you're passing some sensitive information like (ID, password, email, etc.) then make sure to encrypt it. Because anyone can easily find this information in the browser's console if it is passing through Javascript

about 4 years ago · Juan Pablo Isaza Report

0

Is it good practice to use razor pages directives inside javascript tags to pass model property values

Yes.When you use js to call razor page handler,it is sending a request to razor page handler in js,and getting the response of it.So it is safe.

Here is a demo using ajax to get data from handler:

function Test() {
            $.ajax({
                url: '?handler=Test',
                type: 'GET',
                success: function (data) {
                    //getting data here
                },
                error: function (result) {
                   
                }

            });
        }

handler:

public xxx OnGetTest(){
            //return data here
        }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!