Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3442692
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:42:00+00:00 2026-05-18T08:42:00+00:00

In a Razor View Engine template, I want to do the following: I want

  • 0

In a Razor View Engine template, I want to do the following: I want to put some code between the double quotes of an html attribute. The trouble is that the piece of code I want to insert contains some double quotes itself.

<a href="Url.Action("Item", new { id = Model.Item.Id, page = page });">@page</a>

You can easily see how things turn horribly wrong 🙂 I know i can calculate the link in a variable and then use it, but I’d rather not:

@{ var action = Url.Action("Question", new { id = Model.Question.Id, page = page }); }                   
<a href="@action">@page</a>                                        
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:42:01+00:00Added an answer on May 18, 2026 at 8:42 am

    You don’t need to escape or anything using Razor. Razor is smart enough to know when quotes are within attributes because you’re escaping outside of html when you parse it.

    <a href="@Url.Action("Item", 
           new { id = Model.Item.Id, page = page })">@page</a>
    

    That code will work fine – Just make sure you have the @ symbol in front of the Url.Action call because if you don’t it won’t be parsed properly and I notice you don’t have it in your question.

    Edit: removed ; as Url.Action is not a statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the razor view engine, I have some code like the following: @Html.TextAreaFor(model =>
The Razor view engine automatically differentiates between Server code and Html Code For example
i am using Razor view engine's dll do to some templating in my code
Using the following: MVC 3 VB.NET RAZOR VIEW engine Html Helper Class In my
I'm using the Razor view engine to render some HTML which will then live
Which setting determines the style for the Razor view engine code in HTML?
I have the following in my Razor view for an editor template in my
I am using MVC 4 with Razor view engine. I want to display a
I am using razor view engine and having a bit of trouble creating a
I want to add file extension to razor view engine other than cshtml .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.