Shared folders in the root of a Solution - asp.net

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

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.

Hashlocation strategy in angular on top of ASP.net application

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.

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?

Setting up application and resource folders in sub virtual application

I am looking to use the below asp.net 4.0 web application structure but not quite sure how to achieve my result as explained below. What configuration will be needed to handle path issues for referencing both. For example ~/css/style.css needs to dig into the WEBSITE. I know I will have to create a helper for RESOURCES -- WebResourcePath("images/image1.jpg") returns full path if that works in a separate virtual directory?
Default Web Site
>SAR-GROUPS
SARGROUPS_WEBSITE
SARGROUPS_RESOURCES
All website files like aspx, js, css, etc. normal web files go in the WEBSITE folder. The RESOURCES folder will contain other files like pdfs, xml, txt, images, and files . These files will not need to be uploaded or updated during deployments and can remain untouched. When I deploy the WEBSITE I only need to delete the WEBSITE folder and copy the new precompiled folder in SAR-GROUPS again. I have to deploy like this as it is automated deployment from scrips that run so this is an xcopy deployment.
Does anyone have good practices or a working setup to achieve this. I am not looking at alternate methods unless it cannot be done or the other way is much better for auto builds.
Thanks
If the files in the SARGROUPS_WEBSITE directory need to reference resources in the SARGROUPS_RESOURCES directory then why not just make the SARGROUPS_RESOURCES virtual directory inside the SARGROUPS_WEBSITE directory? This way you can point the SARGROUPS_RESOURCES virtual directory at a physical location on the disk and delete the contents of SARGROUPS_WEBSITE without touching the resources.
So structure would be
Default Web Site
>SAR-GROUPS
SARGROUPS_WEBSITE
SARGROUPS_RESOURCES
But the physical structure could be anything
You can then reference them like
~/SARGROUPS_RESOURCES/css/style.css
*untested
EDIT
You've totally not understood my answer and/or virtual folders.
Physical structure example:
D:\Inetpub\WEBSITE
D:\Inetpub\RESOURCES
IIS structure:
IIS Root -> Site (that is a website and points to D:\Inetpub\WEBSITE)
IIS Root -> Site > Resources (that is a virtual directory and points to D:\Inetpub\RESOURCES)

adding .net code to a classic asp website, can't reference namespaces in .dll file

I have an existing fairly large classic asp website, with virtual directories configured to centralize certain resources. My problem is for some reason I can't access any of my namespaces and classes. I tried adding a reference to another project where I have classes in a namespace "DAL" and even though intellisense sees the classes and the website compiles fine, it errors when I try to access any page that references a class in the "DAL" namespace.
I get the following error message in my browser "CS0103: The name 'CMS' does not exist in the current context". Part of the problem is website project's root is not the same folder/level as the web root in IIS. So my libraries are in the website root "/bin" folder, but iis is looking for these files in the IIS webroot which is at a lower level. So how can I get .net to see my binaries without putting them in the lower IIS website root directory? I tried setting up a virtual directory to my .dll file but it seems to have no effect.
thank you for your help!
======================CLARIFICATION====================
What I'm trying to do is keep the .dll files I want my website to use in a higher level directory then the folder I have set as the web root in IIS. So say the library i want to use it "DAL" it in the projects /bin folder, but under IIS the default site's Local Path is set to "/site/default". The only way I can seem to use the "DAL" library is by putting the /bin folder into "/site/default/bin", which for this project is not an option. Does this help?
Using an NTFS Junction Point to achieve what sounds like the same goal has been working for me.
By way of an example, I have a web site with 20+ child IIS Applications that are largely identical (don't ask!), rather than duplicating the 'bin' folder in each of these (they would be identical) each child application has a 'bin' junction that points to the 'bin' folder in the web site root.
/bin <- this is the actual 'bin' folder
/app1
/app1/bin <- this is a junction point
/app2
/app2/bin <- this is a junction point
/app3
/app3/bin <- this is a junction point
/images
...
...
To create these junction points, if you're using Vista/Win2k8 or later you can use the built-in command 'mklink', for earlier versions of Windows use the SysInternals junction.exe tool - available here.
Maybe make the website route folder a nested application in IIS?

Resources