Hashlocation strategy in angular on top of ASP.net application - asp.net

I'm currently building a feature angular application on top of an asp.net application. I want the angular module to load on all pages but not interfering with the routing of the asp.net application.
I achieve this by using hashlocation strategy but the problem is that some modules are not found when navigating in the application. The bundels are placed in a folder called "plugins"
For instance
localhost:/foo1 - WORKS
localhost:/foo1/foo2 - One module not found (looks in foo2/plugins folder)
localhost:/foo1/foo2/foo3 - Custom themes not found and module not found (looks in foo2/foo3/plugins)
Is there a way to set the deploy url in angular cli to a relative base folder as to look for files in /plugins disregarding the current url?

Is Static files are allowed in your .net app ?
For example in .net core, be default static files allowed and all files from wwwroot folder you can use in ur application.

Related

Referencing assets in ASP.NET Core

I started with an ASP.NET MVC Core 2.1 project. Then, I loaded a 3rd party theme (html/css/javascript/fonts) into wwwroot folder of the project. When I open the .html files from wwwroot, all appears fine.
I now want to "cut" the theme into MVC parts -- _Layout.html, views, etc. When html content is placed into MVC views, do I need to prefix every link with "~"? For example, href="css/colors/orange.css" becomes href="~/css/colors/orange.css"? This seems like a lot of work. Is there any way to tell .NET that relative paths are off wwwroot?
And a related question -- I don't have to use MVC - if I used ASP.NET Core non-MVC project, would this not be an issue?
Thanks.
The tilde is used to resolve virtual folders. For example, if I put my app in a virtual folder app1 in IIS, then href="~/path" would be translated to href="/app1/path". If you aren't using virtual folders then you shouldn't need the tilde.
Additional
href="css/colors/orange.css" is relative to the folder you are in. It is expecting css to be a child of the current folder. If you were to add a leading slash then it would be an implied absolute path with the leading slash being root. href="/css/colors/orange.css" would expect css to be a child of your root folder. If you aren't using virtual folders as explained above you would still need to add a leading slash since css will always be a child of root.

How to reorganize contents like the old school in ASP.NET Core MVC?

I have a web site in ASP.NET Core MVC, and I don't want to put my contents inside another folder. I just want to use the old school of creating this file-system architecture at the root of my project's folder:
Styles
Fonts
Scripts
Images
But I can't make ASP.NET Core MVC serving files from them. For example http://domain.test/styles/default.css returns 404.
I've tried to add StaticFileOptions, but I can't get it to work.
Can you help please?
I tried the given solution, that is, to use UseWebRoot("") with empty string to make it refer to the root of my web project. Yet it still returns 404.
I created a Styles folder inside the \bin\Debug\netcoreapp2.0\ and added a Styles.css there and it served the file.
If you are not adding them on the wwwroot folder then you should do more preparation.
This link will help Working with static files in ASP.NET Core
I think before asking you should search some more. For example
this stackoverflow question will help you:
How to Configure an Alternative Folder to wwwroot in ASP.NET Core?

Shared folders in the root of a Solution

I have 3 web application in a solution in VS2010. They use the same CSS, images etc. How can I make a shared folder in the solution's root to access from all web app? So for example I want a "CSS" folder in the root to store the CSS files, and access them from all web application.
Thanks
Structure:
Solution
- Project1
- Project2
- Project3
- Images
- CSS
I want to store css files and images in a central place (at the root folder of the solution), but not inside any of the projects.
As Furqan said, deploy those common elements as their own web application on the server. Then refer to the elements using the full url, such as media.yourcompany.com/css/site.css

two problems with Web Site type project (not Web Application)

I have a project which is a Web Site, not Web Application and have two problems because of that.
I have a custom control derived from BaseValidator which I had to put in the App_Code folder. Now on the page I want to register this control by
<%# Register tagname="mytagname" Namespace="PP" TagPrefix="dv2" %>
But when I get enter to this page, I have exception, because the src attribute is missing. I can't put in the src attr. path to the App_Code because I have another exception. How can I do that? This is a Web Site, so the sources are not compiled to one dll file, so I don't know what to add to the src attribute.
When I want to add to the Web Site a new project library, I have to compile it and manually copy the library dll file to the bin folder in the Web Site. But don't know, how can I debug this library with brakepoints?
This is my first time with Web Site project type. I always created the Web App.
1- Don't use tagname attribute here, tagname is suitable for UserControls.
http://msdn.microsoft.com/en-us/library/c76dd5k1.aspx
2- There is no any difference between using library in a web app or website. Just choose Add Reference from project node's context menu and select your class library from project tab.
Try creating a separate project for your CustomControls and reference it in your WebSite project by the namespace you use in your CutomControls project. Also check out this post for some information asp.net add custom control in website
Your second question, if you keep all of your projects in the same solution and just reference them to each other's projects, you will be able to debug and step into methods and set break points in any of the projects in your solution. If you don't want to do that, you have to copy the debug symbol files along with the .dll to the bin or point VS to where the necessary debug symbol files are located and then you will be able to step through the code in the .dll

symfony routing.yml config for site folders

I have symfony web files in web root folder where the project is running. I have site files such as index.html, aboutus.html and contactus.html files. I have put these files into public_html/site/ How to access these files by default using routing.yml? also project should run in index.php
Hm...If you want to add to your project some static pages, I would recommend you this method.I think this is the right way. For index.php ,well read this
Why don't you make a new module for static pages and move the html content into it?
You have to understand that routing system in symfony is used for connect requested urls to controllers. So you can't use it to provide generating urls for static pages outside of your symfony application. That files are just like files of foreign site.
So you can just use link_to('about us', $this->getRequest()->getHost().'/about_us.html');

Resources