Questions tagged [urlhelper]

113 questions
4
votes
1 answer

UrlHelper mock is not working

I am trying to write get write a unit test that passes but the method my test calls, calls another method which generates a URL using the UrlHelper class. The result of calling urlHelper.Action keeps returning null. I have tried mocking (using Moq)…
floormind
  • 1,868
  • 5
  • 31
  • 85
4
votes
1 answer

Cannot call Action method from UrlHelper on ASP.NET MVC 5.1

I am trying to create unit tests for my ASP.NET MVC 5.1 app. I want to verify the outgoing URL by using the UrlHelper.Action() method. I can do that with ASP.NET MVC 4, but cannot with ASP.NET MVC 5.1. There is an exception when call the Action()…
Louis Nguyen
  • 139
  • 1
  • 1
  • 3
3
votes
1 answer

Rails URL generator switch http / https

Is there a way to put in links to external resources that automatically adds the protocol based on the current protocol? For example I want to show images from Facebook's Graph API. I was hoping I could do something like: image_tag…
Heinrich Lee Yu
  • 1,472
  • 15
  • 31
3
votes
2 answers

Use Rails path helpers from inside an plain old ruby class? (Resque job)

I need to make some API calls from inside a Resque job (which is just a plain old Ruby class) and those API calls need to include URLs to resources on my site. Is it "correct" to just add this to my class definition? include…
d11wtq
  • 34,788
  • 19
  • 120
  • 195
3
votes
2 answers

RuntimeError default_url_options host and root_url (with subdomain)

Each user of my app have a custom url (through subdomain) stored in db. My request is simple, I would like to send the "user url" through a json feed, like this: {user_name: "vincent", :user_url: "vincent.my_app.com"} to do that I have overwrite…
skyporter
  • 847
  • 1
  • 7
  • 14
3
votes
1 answer

Using Url.Content from within a WebForms page incorrectly resolves the tilde

So a long long time ago we added MVC 1.0 to an existing ASP.NET 2.0 WebForms site and during that upgrade we made MVC's UrlHelper available to our existing WebForms code. This meant that within our WebForms code we could do such things as: <%=…
Cain
  • 918
  • 6
  • 9
3
votes
4 answers

Extending Zend\View\Helper\Url in Zend Framework 2

I wrote a simple url view helper, that extends Zend\View\Helper\Url and attached it to the ViewHelperManager: MyNamespace\View\Helper\Url namespace MyNamespace\View\Helper; use Zend\View\Helper\Url as ZendUrl; class Url extends ZendUrl { …
automatix
  • 14,018
  • 26
  • 105
  • 230
3
votes
2 answers

MVC 3 Url Helper Giving Incorrect URL

I am developing a MVC 3 application for a corporate intranet site and I am having some issues with the URL helper sometimes not producing correct URLs. The application is being accessed through an access manager application that is controlled by our…
3
votes
2 answers

Why is url helper in rails putting a "." instead of a "/" in path?

In my app I am working on allowing users to send invitations. The invites have tokens. And in the emails I am linking to a signup page with the token in the path. In the mailer's controller I am…
John
  • 13,125
  • 14
  • 52
  • 73
2
votes
3 answers

UrlHelper extension method call encoded not executed

I created a simple extension method for the ASP.NET MVC UrlHelper. It takes no arguments as its job is to look up the name of a stylesheet file from the configuration and return a url to the stylesheet. The extension method looks roughly like…
user93255
  • 23
  • 3
2
votes
2 answers

Resolve virtual path in MVC

Hi, I got a adress like this : ~/Content/Files/AdImages/20/20_thumb.jpeg, I need this to be resolved. This was done in ASP.net with Control.ResolveUrl(). According to this article…
Banshee
  • 15,376
  • 38
  • 128
  • 219
2
votes
1 answer

UrlHelper extension method not working

I'm trying to add an extension method to my MVC 2 project without success and after several hours of googling and looking here I'm at a loss. I've created a brand new MVC 2 project to make sure there was not anything weird about my existing project…
Chris Dellinger
  • 2,292
  • 4
  • 25
  • 33
2
votes
0 answers

System.ArgumentNullException: Value cannot be null. Parameter name: url

In asp.net mvc application, i am trying to redirect to new route in Application_AuthenticateRequest.If the user is not authenticated, then i am redirecting to different url. Following is the code, protected void…
Hari
  • 73
  • 1
  • 8
2
votes
2 answers

How to inject descendant UrlHelper class into WebViewPage to enable cache busting?

I've overridden UrlHelper.Content() method. Now I want my implementation to be used instead of default UrlHelper class. How can I configure MVC to tell it which class to inject into WebViewPage.Url property? Update 1: The idea is simple. Bundles…
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
2
votes
1 answer

Url Helper route with template placeholderse

I want to iterate through table data and poupulate links in a table. Each row in the table has links of a similar fashion with several different ids interspersed. I'd like to use the Url factory to generate a template for the url route. eg. var…
monkeyhouse
  • 2,875
  • 3
  • 27
  • 42