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 7432899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:31:52+00:00 2026-05-29T09:31:52+00:00

I have an MVC application. After I finished the web site I need to

  • 0

I have an MVC application. After I finished the web site I need to change @url.content behavior.

So I need to override @url.content in all of my website application. How can I do it?

<script src="@Url.Content("~/Scripts/jquery-1.7.1.js")"></script>
<script src="@Url.Content("~/Scripts/ui/jquery.ui.core.js")"></script>
<script src="@Url.Content("~/Scripts/ui/jquery.ui.widget.js")"></script>
<script src="@Url.Content("~/Scripts/ui/jquery.ui.tabs.js")"></script>
<script src="@Url.Content("~/Scripts/ui/jquery.ui.accordion.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.nivo.slider.js")"></script>
<script src="@Url.Content("~/Scripts/jwplayer.js")"></script>
  • 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-29T09:31:53+00:00Added an answer on May 29, 2026 at 9:31 am

    MHF,

    As mentioned in my comments above, i ‘feel’ you should create a bespoke html.image() helper, rather than try to override the url.content() helper, given that your problem is related to images, and not url.content() per se. here’s how i’d approach this:

    public static partial class HtmlHelperExtensions
    {
        public static MvcHtmlString Image(this HtmlHelper helper,
                                    string url,
                                    object htmlAttributes)
        {
            return Image(helper, url, null, htmlAttributes);
        }
        public static MvcHtmlString Image(this HtmlHelper helper,
                                        string url,
                                        string altText,
                                        object htmlAttributes)
        {
            TagBuilder builder = new TagBuilder("image");
    
            var path = url.Split('?');
            string pathExtra = "";
    
            // NB - you'd make your test for the existence of the image here
            // and create it if it didn't exist, then return the path to 
            // the newly created image - for better or for worse!! :)
    
            if (path.Length > 1)
            {
                pathExtra = "?" + path[1];
            }
            builder.Attributes.Add("src", VirtualPathUtility.ToAbsolute(path[0]) + pathExtra);
            builder.Attributes.Add("alt", altText);
            builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));
            return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
        }
    }   
    

    useage:

    @Html.Image("~/content/images/ajax-error.gif", new{@class="error_new"})
    

    Now, the above is purely a ‘lift’ from an old mvc project, with a comment added to give a hint as to what you might do. I haven’t tested this in any way, so caveat emptor 🙂

    good luck

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

Sidebar

Related Questions

I have a MVC application. I added a Service Reference to it. All good.
I have an MVC application which is my marketing website, and two other regular
I have a MVC web application on an intranet and want to be able
I have an ASP.NET MVC 3 / .NET Web Application, which is heavily data-driven,
I have a simple MVC 3 application. I want the site to automatically redirect
I need some functionality in an ASP.NET MVC application and after doing some research,
I have an older ASP.NET MVC application that uses classic web forms views. As
I have a Bootstrapper that looks through all Assemblies in an ASP.NET MVC application
I have a MVC 4 Web Application where I am requiring SSL for a
I have installed MVC 4 and created a new Internet Application. After running the

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.