routes

How to make a catch all route to handle '404 page not found' queries for ASP.NET MVC?

怎甘沉沦 提交于 2019-12-17 04:12:55
问题 Is it possible to create a final route that catches all .. and bounces the user to a 404 view in ASP.NET MVC? NOTE: I don't want to set this up in my IIS settings. 回答1: Found the answer myself. Richard Dingwall has an excellent post going through various strategies. I particularly like the FilterAttribute solution. I'm not a fan of throwing exceptions around willy nilly, so i'll see if i can improve on that :) For the global.asax, just add this code as your last route to register: routes

“The resource cannot be found.” error when there is a “dot” at the end of the url

我们两清 提交于 2019-12-17 02:36:08
问题 I'm using ASP .NET MVC Beta and I get the HTTP 404 (The resource cannot be found) error when I use this url which has a "dot" at the end: http://localhost:81/Title/Edit/Code1. If I remove the dot at the end or the dot is somewhere in the middle I don't get the error. I tried to debug but it I get the error from "System.Web.CachedPathData.GetConfigPathData(String configPath)" before ProcessRequest in MvcHandler. Is "dot" not allowed at the end of a url? Or is there a way to fix the route

Routing in ASP.NET MVC, showing username in URL

孤街醉人 提交于 2019-12-17 02:01:22
问题 Im trying to make a route so I can show the username In the URL like this: http://localhost1234/john Here Is my routeconfig: routes.MapRoute( name: "users", // Route name url: "{username}", // URL with parameters defaults: new { controller = "Home", action = "Index", username = "" } // Parameter defaults ); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); Here Is my HomeController:

Add a prefix to all Flask routes

爱⌒轻易说出口 提交于 2019-12-16 19:58:52
问题 I have a prefix that I want to add to every route. Right now I add a constant to the route at every definition. Is there a way to do this automatically? PREFIX = "/abc/123" @app.route(PREFIX + "/") def index_page(): return "This is a website about burritos" @app.route(PREFIX + "/about") def about_page(): return "This is a website about burritos" 回答1: The answer depends on how you are serving this application. Sub-mounted inside of another WSGI container Assuming that you are going to run this

Add a prefix to all Flask routes

江枫思渺然 提交于 2019-12-16 19:58:18
问题 I have a prefix that I want to add to every route. Right now I add a constant to the route at every definition. Is there a way to do this automatically? PREFIX = "/abc/123" @app.route(PREFIX + "/") def index_page(): return "This is a website about burritos" @app.route(PREFIX + "/about") def about_page(): return "This is a website about burritos" 回答1: The answer depends on how you are serving this application. Sub-mounted inside of another WSGI container Assuming that you are going to run this

Show route between current and desired location on iPhone MapView

匆匆过客 提交于 2019-12-14 03:39:27
问题 I want to show a route on a MKMapView between the current location and a desired location as an annotation. What is the best way to do this? 回答1: ///in .h add delegate MKMapViewDelegate ///in .m file - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLLocationCoordinate2D newcordinate = newLocation.coordinate; CLLocationCoordinate2D oldcordinate = oldLocation.coordinate; MKMapPoint * pointsArray = malloc

Subdomain based on CodeIgniter controller name

為{幸葍}努か 提交于 2019-12-14 03:39:25
问题 Suppose I have this two different module for the site that is under two different controllers. Like, index.php/controller1/... and index.php/controller2/... Now, is it possible to have one of the controller URL in a subdomain? To make it clear, in this example, is it possible to have say, index.php/controller1/... in a URL like mainwebsite.com/... and index.php/controller2/.. . in another URL like controller2.mainwebsite.com/ ? If so, what's the best way to do it? routes.php or .htaccess? And

Laravel 5: Route model binding in a group

坚强是说给别人听的谎言 提交于 2019-12-14 02:49:57
问题 I made a Route model binding in the RouteServiceProvider : public function boot(Router $router) { parent::boot($router); $router->model('article', 'App\Article'); } My route group: Route::group(['prefix' => 'articles'], function(){ //some routes .... Route::group(['prefix' => '{article}'], function(){ Route::get('', [ 'as' => 'article.show', 'uses' => 'ArticlesController@show' ]); Route::get('comments', [ 'as' => 'article.comments', 'uses' => 'ArticlesController@comments' ]); }); });

Google Maps JavaScript API - Show INACTIVE alternative routes in one color, ACTIVE alternative route in another

放肆的年华 提交于 2019-12-13 22:16:52
问题 I am using the Google Maps JavaScript API and am providing directions with alternative routes. I would like to display the INACTIVE alternative routes in a gray color, and the current ACTIVE route in a neon green color. How can I target the inactive and active route states and control their colors? I've been able to change the alternative route colors using Geocodezip's example but now I need to target inactive and active states. Here's an example of the functionality I'm going for for (var j

Rails 3 Routing Error with Nested Resources

对着背影说爱祢 提交于 2019-12-13 21:22:12
问题 In my Rails application, there are many games, and each game has it's own set of leaderboards. It makes sense then, to have the leaderboards nested in the game, so you can only get to a leaderboard through a game. I setup my routes.rb file as such (the important part): resources :games do resources :leaderboards end So then I updated my controller so it would get the appropriate game from the game_id passed in, and grab the leaderboard information from that. However, my issues comes from my