Angular 2 routing does not route - angular2-routing

The issue I am having is that I am not able to navigate to the new component that I created using the routes. It was working and still works fine with other components.
Here is the file where I create the outlet
<router-outlet></router-outlet>. Then I have multiple routing variable that will navigate to the needed parts of the website. With the new component, I am not able to access it. I created a new component and named it RegisterPageComponent. In my app.routing.ts I added a new field to appRouteswith the following format
{
path: 'register',
component: RegisterPageComponent
}
When I try to access localhost:4200/register, I don't get anything. My RegisterPageComponent holds a default works! value

Please read below link and try to implement same solutions.
https://coryrylan.com/blog/introduction-to-angular-routing

Related

Custom Index Swashbuckle/Swagger

this is my first time using Swagger, I'm currently using Swashbuckle.AspNetCore v2.4.0 and trying to implement a custom index page. In this version they have removed the possibility of injecting javascript, and I'm essentially stuck with the only option of making a custom index.html page just to edit some links (most specifically the navigation icon link). I'm trying to get my custom index page to work but I'm having trouble getting it to load.
app.UseSwaggerUI(c =>
{
c.IndexStream = () => GetType().GetTypeInfo().Assembly
.GetManifestResourceStream("customSwaggerIndex.html"); // requires file to be added as an embedded resource
});
I have the following in my code with the customSwaggerIndex.html saved on the wwwroot folder and its Build Action set as Embedded resource, but I keep running into the error System.ArgumentNullException: Value cannot be null. This is most likely due to me not properly writing the GetManifestResourceStream("string"). Any help?
Figured out why it wasn't working. First thing is that it needs the name of the solution, and instead of \ its .
So for example a file located in my wwwroot folder would look like this.
c.IndexStream = () => GetType().GetTypeInfo().Assembly
.GetManifestResourceStream("MySolution.wwwroot.customSwaggerIndex.html");

Editing already defined routes

I'm working on a dynamic project which is adding or changing the route urls.
For example:
I want to add sub application route like AppName/{controller}/{action}/{id}
or maybe a language information like {controller}/{action}/{id}/{language}
in this scenario, I can't touch to other routes and I have to override them.
I tried to foreach RouteTable.Routes and there is no editable values for added routes.
Thanks for any help.
I found the solution.
I cast the items in the RouteTable.Routes to Route object :)

Meteor Check if Template Exists

I have Meteor application that uses Iron-Router in which the rendered screen is dynamic based on the URL.
I have two parameters from the URL, station and screen.
In the routing code:
this.render(stationParam+screenParam, {to: 'content'});
However, I want to be able to check if the template stationParam+screenParam exists.
Is this possible?
All templates are stored as a field of a global object, Template. The question then is: How to check if this global object has a given field?
You have multiple ways to do it. My personal favourite using underscore:
if (_.has(Template, stationParam + screenParam)) { /* ... */ }
Underscore is included in Meteor. If you want to use it in a package, don't forget the api.use('underscore') in your describe callback.
See also: Determining if a javascript object has a given property

ASP.NET Routing Interference Problems

I'm having a mind shattering problem with ASP .NET routing. I can't tell if this is a bug in Microsoft code or if I'm just using it wrong.
The scenario is basically this:
I have a custom route I want to add. In addition, I'm registering ASP .NET DynamicDataRoutes. If I leave out my custom route, all the ASP .NET DynamicDataRoutes work fine. Once I add this before my DynamicDataRoute:
routes.Add(new Route("IgnoreDirectory/{*pathInfo}"), new StopRoutingHandler()));
all the DynamicHyperlinks generated by DynamicData are generated with the wrong root url, like this one:
http://localhost/IgnoreDirectory/MyTable/List
which should be (and was until I added my custom route)
http://localhost/MyDynamicData/MyTable/List
What's weird is that I'm adding my DynamicDataRoute for a COMPLETELY different path:
routes.Add(new DynamicDataRoute("MyDynamicData/{{table}}/{{action}}")
{
Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
Model = model
});
Why is adding a route for IgnoreDirectory causing my DynamicData routes to use a base url of IgnoreDirectory????
I can't figure it out.
I'm going out on a limb here, but I think it has to do with two things. The order that the routes are stored in the RouteTable are significant in that the application will use the first route it finds in order to match the URL.
What I think might be happening here is that the DynamicDataRoute is building itself upon the Route that you are inserting before the DynamicDataRoute in the route table.
The first thing I would do is try moving the Route add after the DynamicDataRoute has been added.
Hope this helps...

ASP.NET MVC 3, IIS7, 404 Error, not routing correctly?

I'm newish to ASP.NET MVC 3, so sorry if I'm my details are slightly murky. I'm trying to publish my web app to a server here. I'm running in IIS 7, set to integrated, and I can get to the home page of the app just fine. However, certain links remove the directory out of the url. Example:
URL of home page:
http://localhost/CMS/ - this will take you to the first screen, with links to "Contract," "Customer," and "Employee." Clicking one of those brings you to...
http://localhost/CMS/Contract (or whichever you choose.) From there, it's broken down into different categories. One of them is "Create Contract." Here's the problem I'm having: that URL points to
http://localhost/Contract/Create - completely omitting the CMS part out and throwing a 404. I can reach it by inserting CMS back inside, and those pages route correctly.
What could be wrong? Let me know if you need more information on any of my code or whatever.
You can define an alternate controller in the route than what you would expect
routes.MapRoute("Contract", "Contract/{action}",
new { controller = "cms", action = "index" }
);
and you should be constructing your links like this within your pages
<%=Html.ActionLink("Contract", "create", "cms") %>
rather than doing it the old fashioned way like
Contracts
which side steps routing.
It sounds like you don't need additional routes but need to create ActionLinks propery using the HtmlHelper
When you are using your paths to to the controller actions you need to use #Url.Action("action", "controller"); instead of just using "action\controller".
See an example http://codetuner.blogspot.com/2011/07/jquery-post-url-problems-in-iis-hosted.html

Resources