urlhelper

Redirect with CodeIgniter

爱⌒轻易说出口 提交于 2019-11-27 03:27:21
Can anyone tell me why my redirect helper does not work the way I'd expect it to? I'm trying to redirect to the index method of my main controller, but it takes me www.mysite.com/index/provider1/ when it should route to www.mysite.com/provider1 . Does this make sense to anyone? I have index page in config set to blank, although I don't think that it is the issue. Does anyone have advice on how to fix this issue? Thanks in advance! Controller : if($provider == '') { redirect('/index/provider1/', 'location'); } .htaccess : RewriteEngine on RewriteCond %{REQUEST_URI} !^(index\.php|files|images|js

ASP.Net Core 2.0: Creating UrlHelper without request

爷,独闯天下 提交于 2019-11-27 02:32:54
问题 I'm working on creating a UrlHelper for a background worker to create callback urls, which means it's not part of a normal request where I could just ask for it through DI. In ASP.Net 5 I could just create a HttpRequest and give it the same HttpConfiguration I used to build my app, but in ASP.Net Core 2.0 the UrlHelper depends on a full ActionContext which is a bit harder to craft. I have a working prototype, but it's using a nasty hack to smuggle the route data out of the application startup

Call UrlHelper in models in ASP.NET MVC

前提是你 提交于 2019-11-26 17:03:59
I need to generate some URLs in a model in ASP.NET MVC. I'd like to call something like UrlHelper.Action() which uses the routes to generate the URL. I don't mind filling the usual blanks, like the hostname, scheme and so on. Is there any method I can call for that? Is there a way to construct an UrlHelper? Helpful tip, in any ASP.NET application, you can get a reference of the current HttpContext HttpContext.Current which is derived from System.Web. Therefore, the following will work anywhere in an ASP.NET MVC application: UrlHelper url = new UrlHelper(HttpContext.Current.Request

ASP.NET MVC: Unit testing controllers that use UrlHelper

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 12:40:49
One of my controllers actions, one that is being called in an Ajax request, is returning an URL to the client side so it can do a redirection. I'm using Url.RouteUrl(..) and during my unit tests this fails since the Controller.Url parameter is not pre-filled. I tried a lot of things, among others attempting to stub UrlHelper (which failed), manually creating a UrlHelper with a RequestContext that has a stubbed HttpContextBase (which failed on a RouteCollection.GetUrlWithApplicationPath call). I have searched Google but found virtually nothing on the subject. Am I doing something incredibly

Redirect with CodeIgniter

白昼怎懂夜的黑 提交于 2019-11-26 07:30:01
问题 Can anyone tell me why my redirect helper does not work the way I\'d expect it to? I\'m trying to redirect to the index method of my main controller, but it takes me www.mysite.com/index/provider1/ when it should route to www.mysite.com/provider1 . Does this make sense to anyone? I have index page in config set to blank, although I don\'t think that it is the issue. Does anyone have advice on how to fix this issue? Thanks in advance! Controller : if($provider == \'\') { redirect(\'/index

Call UrlHelper in models in ASP.NET MVC

纵饮孤独 提交于 2019-11-26 05:14:55
问题 I need to generate some URLs in a model in ASP.NET MVC. I\'d like to call something like UrlHelper.Action() which uses the routes to generate the URL. I don\'t mind filling the usual blanks, like the hostname, scheme and so on. Is there any method I can call for that? Is there a way to construct an UrlHelper? 回答1: Helpful tip, in any ASP.NET application, you can get a reference of the current HttpContext HttpContext.Current which is derived from System.Web. Therefore, the following will work