How to share resources among multiple Websites or Web Applications?
To share ASP.NET MVC dependent resources like Script files, CSS files, and DLL files among multiple websites or web applications, host them in a common shared location. This hosting can be done locally in a server and shared across multiple projects.
Host the Scripts and CSS files
To host the Script and CSS files, add a virtual directory in the existing website in IIS. It can be added to any existing website or create a new one. To create a new website, right-click the site in IIS and select Add Website.
Then, provide configurations for Add Website dialog and select OK.
Now, a new website has been created. Add the CSS and Scripts in the site to host them. The previously given steps can be skipped if the website is already available. In the physical location of the hosted site’s folder, add the scripts and CSS files.
After adding the files, right-click the website name in the Connections panel and select Refresh. This will update the changes in the site.
Now, the site is hosted. To access it, right-click the website and select Manage Website and then Browse.
From here, you can directly provide a path for the Script or CSS files to load them or enable directory browsing in the features view of the website and browse the contents.
Host the Assembly files
Now, the script and theme files have been hosted. The dependent assemblies are hosted by creating a private NuGet server. This is done with the help of Nuget.Server package provided by .NET Foundation. This package creates an ASP.NET application that can host a package feed on any server that runs IIS. This is as simple as creating an Web application with Visual Studio.
Create a new Web application in Visual Studio. Make sure that the project’s Framework is in 4.6 or above, since Nuget.Server supports only above Framework 4.6.
In this dialog, select the Empty template, then select OK. After creating the application, go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Browse for Nuget.Server package and install it.
Now, the empty Web application is converted into a package source. It also installs a variety of other packages. Select “I Accept” to agree to the license terms and install the packages.
The Nuget.Server package installation creates a Packages folder in the application and modifies web.config to include additional settings for the private Nuget Server.
Make sure that there are no duplicate configurations in the web.config file after the installation.
The duplicate configuration added by the installation will lead to an internal server error when you host it. So, remove the element with older framework version.
Add .nupkg files to the Packages folder in Visual Studio.
To make packages available when the application is published to a server, set each one's Build Action to Content and Copy to Output Directory to Copy always in the Properties window.
Now, press Ctrl + F5 to run the application without debugging.
The OData feed of added packages is found in the previously given page. After the application is deployed, the “http://<domain>/nuget “ is added to the Package Sources and used as a private Nuget Server.
Conclusion
I hope you enjoyed learning about how to share resources among multiple Websites or Web Applications.
You can refer to our ASP.NET MVC feature tour page to know about its other groundbreaking feature representations. You can also explore our ASP.NET MVC documentation to understand how to present and manipulate data.
For current customers, you can check out our ASP.NET MVC Controls from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our ASP.NET MVC and other ASP.NET MVC controls.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!