Server-side code blocks (
<% ... %>
) only run in ASP.NET pages / controls. They do not execute in static files like Javascript (
*.js
) or CSS (
*.css
).
You'll need to keep the server-side code block in your page, and find some other means to pass it to your Javascript file.
For example:
YourPage.aspx:
...
<body>
<script>
const appSettings = {
Data: "<%$ AppSettings:Data %>"
};
</script>
...
YourScript.js:
function LoginAES)({
const data = window.appSettings.Data;
alert(data);
}
NB: Your method name makes me think you are trying to hash the user's password on the client before submitting it to the server. That is a
terrible idea! Aside from the fact that you won't be able to salt the password correctly, you effectively negate any benefits of hashing the password. The hash value is now the plain-text password, and you are storing that in your database verbatim.
If you're worried about someone intercepting the form submission between your users and your server, then make sure you site is only available over HTTPS. That way, the system will encrypt the data in-transit, and you can forget about trying to hash the password on the client, and do it properly instead.
Secure Password Authentication Explained Simply[
^]
Salted Password Hashing - Doing it Right[
^]
Troy Hunt: Here's Why Your Static Website Needs HTTPS[
^]