0

Im am doing an MVC Application, and I have to Redirect to a plane HTML page. I need to show the user name.

I think the only way to pass value from Controller to HTML Page is via Session Value.

Here is my code

 public ActionResult Index()
        {
            Session["Username"] = "My Name";
            return new FilePathResult("pagehtml", "text/html");
            }

In My HTML page I set this

<!DOCTYPE html>

<script type='text/javascript'>
    var userID = '<%=Session["Username"]%>';
    alert(userID);
</script>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <h1>My Page</h1>
</body>
</html>

the problem is that alert(userID);

Shows <%=Session["Username"]%> instead of the value.

How can i get Session value? or if there another way to pass value from Controller to an standar HTML..

thanks

Diego
  • 2,238
  • 4
  • 31
  • 68

0 Answers0