问题标签 [urlhelper]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - convert string into (object) routeValues C#
I am writing an extension function for UrlHelper. This function will accept three String parameters. First param is ACTIOn, second is CONTROLLER and third is some RANDOM STRING.
example: url.customeURL("Index", "Home", "view=someview");
After accepting all these parameters, Extension function will return a URL with action, controller and a query string something like;
Here is my function:
The problem I am facing with my current implementation is, when I pass PARAMETERS to routeValues object it makes the URL like:
Whereas I want it to create an URL like:
So is there anyway I can achieve this? I know this can be easily done with Url.Action("Index", "Home", new {"view=someview"})
But I have to do it with an extension function.
c# - How to solve "invalid anonymous type member decelerator" error
I have created an Extension function for UrlHelper which simplifies the writing of parameters. It just accept two string parameters and return a string of desired format. In my case it work like this:
The problem I am facing now is when I use this function inside the URL.ACTION more than once it gives me an "invalid anonymous type member decelerator" error. Can someone tell me how can I solve this problem?
Example:
Just to clarify:
is another Extension function which avoids the programmer to write the code for extracting the routeData values.
c# - 从 RouteValueDictionary 对象创建字符串/查询字符串
我已经UrlHelper
为不同的用途创建了扩展功能。现在我正在创建一个函数,它将接受三个参数,例如:
在扩展函数中,我将RouteValueDictionary
像这样对其进行迭代:
但现在我需要知道,在迭代这些键和值时,如何生成字符串或查询字符串,例如:
所以我可以创建一个最终 URL 并在其中传递这个字符串,如下所示:
或者任何正确的方法。
configuration - Issue with Compass/Sass config.rb
I am trying to update my asset directories within my scss config.rb file. I need to access compass mixins such as height: image-height($image); For this to work, my images path has to be relative to my project’s image directory, defined in your config.rb file. However, I cannot get this to work. I have used the compass url_helpers but nothing seems to be changing. No matter how I update the assets in my config.rb, the following is returned when declaring an image variable in my scss..."No such file or directory @ rb_sysopen - /private/var/www/websites/gc/app/sites/all/themes/merge/scss/../images/../search-b-image.jpg" Where is this ../images/.. coming from if its not in my config.rb? Any help is much appreciated.
config.rb file is:
asp.net-mvc - System.ArgumentNullException:值不能为空。参数名称:url
在 asp.net mvc 应用程序中,我试图重定向到 Application_AuthenticateRequest 中的新路由。如果用户未通过身份验证,那么我将重定向到不同的 url。以下是代码,
在上面的代码中,即使在 Application_Start 事件发生路由注册后,urlHelper.Action 方法也会返回空字符串。
任何想法来解决这个错误?
以下是Application_Start中的RouteConfiguration,
c# - MVC 6 IUrlHelper 依赖注入
我想通过依赖注入来使用 IUrlHelper,以便能够使用它的功能为不同的休息端点生成 uri。我似乎无法弄清楚如何从头开始创建 UrlHelper,因为它在 MVC 6 中发生了变化,并且 MVC 不会自动在 IoC 控制器中提供该服务。
设置是我的控制器将内部模型接收到 api 模型转换器类并使用 IUrlHelper(全部通过依赖注入)。
如果有更好的替代 IUrlHelper/UrlHelper 我可以用来为我的 WebApi 操作/控制器生成 Uris,我愿意接受建议。
ruby-on-rails - 如何从观察者模型的钩子(rails4)中使用多态路径
我可以app.polymorphic_path(MyModel.first)
从控制台使用。但没有什么是这样的:
ETC
c# - UrlHelper.Action 抛出 ArgumentNullException
我正在使用 UrlHelper 生成 URL,但是,当我调用方法 Action(action, controller, route) 时,我得到了 ArgumentNullException。
我创建了一个辅助函数,它为我创建了对象路由值(并且它工作正常)。
最奇怪的是它已经在控制器内部工作,但是,它没有在单独的类中工作(如 BusinessLayer/Facade)。
所有参数都不是空值。
它一直在从 Task 方法调用。
我也试图得到这样的上下文:
但它 HttpContext.Current 正在返回 null 给我。
c# - UrlHelper.Route 和 UrlHelper.Link 方法有什么区别?
查看 msdn(UrlHelper.Route,UrlHelper.Link),它们看起来完全一样。有任何理由使用其中一个吗?