routing

Routing optional parameters in ASP.NET MVC 5

↘锁芯ラ 提交于 2019-11-27 21:55:19
I am creating an ASP.NET MVC 5 application and I have some issues with routing. We are using the attribute Route to map our routes in the web application. I have the following action: [Route("{type}/{library}/{version}/{file?}/{renew?}")] public ActionResult Index(EFileType type, string library, string version, string file = null, ECacheType renew = ECacheType.cache) { // code... } We only can access this URL if we pass the slash char / in the end of url , like this: type/lib/version/file/cache/ It works fine but does not work without / , I get a 404 not found error, like this type/lib/version

javascript clientside routing/pathing library [closed]

自作多情 提交于 2019-11-27 21:49:47
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I'm in the need for a routing library to handle my paths for a client side js app. I'm currently using backbone.js, which while great,

Rails: Parse route information from URL

断了今生、忘了曾经 提交于 2019-11-27 21:42:24
问题 How can I parse url string to hash like {:controller => 'controller_name', :action => 'action_name', :id => 'id'} ? 回答1: In Rails 3 you can do the following: Rails.application.routes.recognize_path "/accounts/1" # {:action=>"show", :controller=>"accounts", :id=>"1"} Using ActionController::Routing::Routes.recognize_path kept throwing ActionController::RoutingError Exception: No route matches "/accounts/1 回答2: You may be able to use ActionController::Routing::Routes.recognize_path , depending

How to determine if an arbitrary URL matches a defined route

浪尽此生 提交于 2019-11-27 20:40:51
How can I tell if a string matches a particular named route? I have a route like this: routes.MapRoute( "FindYourNewRental", "find-your-new-rental/{market}/{community}.html", new { controller = "FindYourNewRental", action = "Community" } ); string url = "http://www.website.com/find-your-new-rental/northerncalifornia/sacramento.html" How can I programmatically tell if the 'url' string matches that route? Something like this: // matches url with the named route "FindYourNewRental" if (IsRouteMatch(url, "FindYourNewRental")) { // do something } public bool IsRouteMatch(string url, string

Basic Rails 404 Error Page

我与影子孤独终老i 提交于 2019-11-27 20:15:54
问题 I have been looking for a simple answer to this for a ridiculously long time and it seems like this has to be so plainly obvious and simple because no one has an easy, idiot proof tutorial. Anyway, all I want to do is to have a single 404.html static page that loads whenever ANY error is thrown. Ideally this should only happen in production and staging. I feel like this should be the easiest thing to do... but I can't figure it out. Any help is much appreciated. 回答1: in your

Passive Link in Angular 2 - <a href=“”> equivalent

感情迁移 提交于 2019-11-27 20:09:04
问题 In Angular 1.x I can do the following to create a link which does basically nothing: <a href="">My Link</a> But the same tag navigates to the app base in Angular 2. What is the equivalent of that in Angular 2? Edit: It looks like a bug in the Angular 2 Router and now there is an open issue on github about that. I am looking for an out of the box solution or a confirmation that there won't be any. 回答1: If you have Angular 5 or above, just change <a href="" (click)="passTheSalt()">Click me</a>

Laravel previous and next records

浪尽此生 提交于 2019-11-27 20:05:18
问题 I am trying to create a page where I can see all the people in my database and create edits on them. I made a form where I fill in the data from the database of certain fields. I would like to navigate trough them by a Next and Previous button. For generating the next step I have to take the ID larger than the current one to load the next profile. For generating the previous step I have to take the ID smaller than the current one to load the previous profile. My route: Route::get('users/{id}'

Authentication on Server side routes in Meteor

倾然丶 夕夏残阳落幕 提交于 2019-11-27 19:54:14
What is the best way (most secure and easiest) to authenticate a user for a server side route? Software/Versions I'm using the latest Iron Router 1.* and Meteor 1.* and to begin, I'm just using accounts-password. Reference code I have a simple server side route that renders a pdf to the screen: both/routes.js Router.route('/pdf-server', function() { var filePath = process.env.PWD + "/server/.files/users/test.pdf"; console.log(filePath); var fs = Npm.require('fs'); var data = fs.readFileSync(filePath); this.response.write(data); this.response.end(); }, {where: 'server'}); As an example, I'd

MVC2 Routing with WCF ServiceRoute: Html.ActionLink rendering incorrect links!

折月煮酒 提交于 2019-11-27 19:43:41
I have a WCF service that lives side-by-side with an MVC2 web site. I'd like for my URL for the service to look like this: http://localhost/projdir/Service The MVC site is in its infancy so it still has all its boilerplate controllers etc. The following code works at first glance in global.asax: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.Add(new ServiceRoute("Service", new ServiceHostFactory(), typeof(MyService))); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new {

Enforce Https routing for login with play framework

浪尽此生 提交于 2019-11-27 19:06:46
I want to enforce https routing for the login page only of my application. Is it possible to do so with Play! without the use of a front end http server? You can use an @Before interceptor to redirect every request, even if the user types http:// directly. Below is the code that I use (it works when running containerless play run , or when running behind a front end such as on Heroku). public class HttpsRequired extends Controller { /** Called before every request to ensure that HTTPS is used. */ @Before public static void redirectToHttps() { //if it's not secure, but Heroku has already done