How to concatenate a partial url with @model.hyperlink

Topics: Writing modules
Dec 16, 2011 at 3:59 PM
Edited Dec 16, 2011 at 3:59 PM

I am pulling a partial hyperlink from the DB: /mkt_info/audioconf/ARCV_BadAttitudes.asp


I need to concatonate it with the full url htttp://

in my Razor syntax.



<a href=""</a>

Not sure how make this happen. Anyone have any idea?

Dec 16, 2011 at 4:05 PM
Edited Dec 16, 2011 at 4:11 PM

Try this...

Add a @using System.IO and then this:

<a href="@Path.Combine("", webinar.LearnMoreLink)"</a>

I did not actually test this but it should work.

Dec 16, 2011 at 4:46 PM

Not working :(

Dec 16, 2011 at 5:17 PM
Edited Dec 16, 2011 at 5:22 PM

I screwed it up...figures.  Try:

 <a href="@Path.Combine("", webinar.LearnMoreLink)">The Link</a>

I just checked this and it works...Sorry!

Dec 16, 2011 at 6:50 PM

No no no no no no. Path.Combine is for file system paths, not URLs.

Dec 16, 2011 at 9:30 PM

This worked:


<a href="" target="_blank" class="learnmore">Learn More >></a>
Dec 16, 2011 at 11:32 PM

Bertrand - True, Path.Combine should probably not be used for this but, it does work.

Oceantrain - I am glad you got it working.

Dec 17, 2011 at 12:19 AM

Not really: it will put backslashes in there instead of forward slashes.

Dec 17, 2011 at 12:57 AM

Hmmm....that is wierd because I put it on one of my views and it new what to do.  I think it had to do with the first parameter being recognized as a URL and it added the appropriate '/'.

Dec 17, 2011 at 1:29 AM

It's really the wrong way to do it; instead you should add @using Orchard.Mvc.Extensions, then use @Url.AbsoluteAction if it's at all an MVC controller you're linking to, otherwise use @Url.MakeAbsolute if you simply wish for an absolute url. This way if your application runs in a virtual subfolder (e.g. localhost/OrchardLocal) you will still get correct links.

Dec 17, 2011 at 2:38 PM

I agree...I went the way I did because the module (not a core Orchard module nor a Science Project one) used it.

I was wrong!  Should not have offered it as a solution.

Many apologies.