url-routing

URL helper in JavaScript

一笑奈何 提交于 2019-11-30 07:19:06
I'm using jQuery Lightbox for my image gallery. The URL for the button image is ' ../../Content/Lightbox/lightbox-btn-next.gif ' That works fine if my URL is ' localhost/Something1/Somtehing2 ' If I use another route like ' localhost/Something1/Something2/Something3 ' then URL to button images is incorrect. Can I use Url.Action() inside .js files? This is how I call .js files: <script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery.lightbox-0.5.js") %>"></script> You can't use Url.Action() inside .js files. But you can define global variable and use it in you js file. <script

ASP.NET MVC Routing / SEO Friendly URL

此生再无相见时 提交于 2019-11-30 07:12:57
I'm trying to do something like stackoverflow Take a link from stackoverflow for example: Hidden Features of C#? if you remove the last part ( Hidden Features of C#? ) it still returns the same result. For my routing in Global.asax I tried doing something like "{action}/{id}/{title}" On my page, this is my link: <%= Html.ActionLink(video.Title, "Details", "Videos", new {id = video.ID, title = video.Title.Replace(" ", "-")}, null) %> This does what I want it to do for the most part except that after the id it throws in " ?title=blah-blah-blah " I want it to say " id/blah-blah-blah " What's my

Vue.js redirection to another page

守給你的承諾、 提交于 2019-11-30 06:17:39
问题 I'd like to make a redirection in Vue.js similar to the vanilla javascript window.location.href = 'some_url' How could I achieve this in Vue.js? 回答1: If you are using vue-router , you should use router.go(path) to navigate to any particular route. The router can be accessed from within a component using this.$router . Otherwise, window.location.href = 'some url'; works fine for non single-page apps. EDIT : router.go() changed in VueJS 2.0. You can use router.push({ name: "yourroutename"}) or

How to trigger the Backbone.Router events in Backbone.js?

倖福魔咒の 提交于 2019-11-30 03:54:36
Router in Backbone.js is responsible for routing client-side pages, and connecting them to actions and events based on urls. But how to trigger the url change? I mean if the only way to do this is to enclose the element associated with page routing in <a> tag. Because I have associated the mousedown and mouseup events with the element used for routing, if I put it in <a> tag, the mousedown and mouseup events will definitely become invalid as it will have conflict with the click event of <a> tag. So is there other ways to make the routing? You can use Router#navigate : navigate router.navigate

AngularJS Restful Routing

落花浮王杯 提交于 2019-11-30 03:50:02
问题 I'm trying to structure my app using the Restful/Ruby convension /<resource>/[method]/[id] . How I've done it previously when using a server-side MVC framework like CodeIgniter was to dynamically route based on the URI: ex. www.foo.com/bar/baz/1 The app would then use method baz in controller/class bar and return views/bar/baz.php (populated with data from bar->baz ) I would like to do the same in Angular, but I'm not sure if it supports this (and if it does, I'm not sure exactly how to go

How can I reload the current page in Ruby on Rails?

萝らか妹 提交于 2019-11-30 03:06:48
I currently have a login popup in my header bar which is on every page in my website. I want to be able to reload the current page that the person is on after a successful login. How do I do this in the controller? def create #declaring and defining user variable stuff if user.save #reload current page <--how do I do this? end end Thanks For my application, I use redirect_to :back and it does the trick. However, I doubt this might have an error in a non general use case(s) (user came from a special page?) but i haven't found it so far in my app. Archonic If you're looking for a way to get the

How to detect language from URL in Sinatra

谁说我不能喝 提交于 2019-11-30 02:31:48
I have a multi-language website and I'm puting the language in the URL like domain.com/en/. When the user doesn't put the language in the URL I want to redirect him to the page in the main language like "domain.com/posts" to "domain.com/en/posts". Is there an easy way to do this with Sinatra? I have more than one hundred routes. So doing this for every route is not a very good option. get "/:locale/posts" do... end get "/posts" do... end Can someone help me? Thanks Use a before filter, somewhat like this: set :locales, %w[en sv de] set :default_locale, 'en' set :locale_pattern, /^\/?(#{Regexp

ASP.NET Routing with Web Forms

笑着哭i 提交于 2019-11-30 00:39:42
I've read ASP.NET Routing… Goodbye URL rewriting? and Using Routing With WebForms which are great articles, but limited to simple, illustrative, "hello world"-complexity examples. Is anyone out there using ASP.NET routing with web forms in a non-trivial way? Any gotchas to be aware of? Performance issues? Further recommended reading I should look at before ploughing into an implementation of my own? EDIT Found these additional useful URLs: How to: Use Routing with Web Forms (MSDN) ASP.NET Routing (MSDN) How to: Construct a URL from a Route(MSDN) Not sure if this is your answer but this may get

How can I override a .svc file in my routing table?

六眼飞鱼酱① 提交于 2019-11-29 23:44:30
I have this URL that was used from some JSON post back from the main website: http://site/Services/api.svc/UpdateItem We are in the process of updating the web site slowly to ASP.Net MVC 2 and don't want to break any current URL's in the system. (JavaScript refresh issues) I have deleted the /Services/api.svc and have moved the logic for this API call into the following Controller: http://site/LegacyApi/UpdateItem Unfortunately, when adding the route, I can't seem to get it to override the api.svc and keep getting a 404 error. Route: routes.MapRoute( "UpdateItemApi", "Services/api.svc

Internationalization and Search Engine Optimization

99封情书 提交于 2019-11-29 23:09:09
I'd like to internationalize my site such that it's accessible in many languages. The language setting will be detected in the request data automatically, and can be overridden in the user's settings / stored in the session. My question pertains to how I should display the various versions of the same page based upon language in terms of the pages' URL's. Let's say we're just looking at the index page of http://www.example.com/ , which defaults to English. Now if a French-speaker loads the index page, should I simply keep the URL as http://www.example.com/ , or should I have it redirect to