This seems like a pretty common use case, but I can't for the life of me find any information on how to set this up.
I've got an "Admin" site where I upload images and then my normal website (separate project) where I need to display those images. Both projects need to be able to display the images (so I can't just simply store them in the website's project directory and call it a day).
In production, this is a no-brainer. I just set up a virtual directory in IIS, but developing in Visual Studio, there's no direct support for this. I've seen things online that tell you do go into the IIS Express config files and add the virtual directory manually, but there's two huge problems with this: 1) I'm in a multi-developer environment and making every developer do this in a consistent way manually is a no-go and 2) there's no automated way to reference this static directory in my code, so that's going to entail a lot of hard-coding paths to image references, which is a hugely bad idea.
I'm aware, also, that I can create links in my project, but I'm dealing with uploads, not static resources that I know about at design time, so creating links for every new upload manually in my project (especially when this is only for testing in development) is insane.
So what is the best way to dynamically share resources between projects just for the purposes of development in Visual Studio?
For what it's worth, these are both ASP.NET MVC 4 projects and I'm using Visual Studio 2012 on a Windows 7 box.
EDIT I should specify that upon uploading the image, a relative path to that image is stored in a database table. I suppose my real issue is in resolving that partial path into a real accessible URL from an entirely different project. If I was in the same project, I would simply to something like Url.Content(Model.ImageUrl), but this obviously won't resolve if the image is not actually in the same project.
It was pointed out to me that I'm over-thinking this.
In production, the files would of course be served through some virtual directory, but in development, it doesn't matter where they're served from. So, all I really need to do is add an app setting for the static URL prefix to prepend to the relative image URL.
For development it would just be the localhost + port of my admin site.
Then, in my release web.config transform, I would just change it to the production URL, i.e. something like "http://static.mydomain.com". In my app code, I just look up this app setting and prepend it to my relative image URL and I'm golden.
If I run into any problems with this approach, I'll note them here with appropriate solutions, once I get a chance to actually implement it.
Related
I have a ASPNET Core application that works fine on my machine with URL https://localhost:5001/, but not on the client's server, where the application's URL is https://example.com/subfolder/.
The problem seems to be an error in a redirect on one of the pages, where a user is sent to /something rather than /subfolder/something. I'm using relative URL's only. In the rest of the application, redirects work fine.
I was wondering if it is possible to debug the application in Visual Studio and have it run in a subfolder, preferably using Kestrel, but IIS Express might be an option too.
Update after comments While adding specifics about the problem, I found out that I was looking at it from the wrong angle. The actual problem seems to be that the application is started as https://example.com/subfolder (no trailing slash). Redirecting to ./something (or just something) will result in https://example.com/something.
(My real question therefore would be: If https://example.com/subfolder is opened, how can I redirect to https://example.com/subfolder/? I'll first try to fix this myself, maybe it should be configured in the webserver. In the meantime, I'd still like to know if subfolders can be used in debugging)
In development, it seems you can't debug your program in subfolder.
I don't recommand you to spend a lot of time to serach how to do that, and I also suggest you use IIS. Because in IIS, it supports Virtual Application, and I think it is you want.
Steps:
create a main website, and create a virtual application.
choose the project folder as Physical Path, mainsite and virtualapplication.
open vs2019 as administrator, maybe you need open it twice,and one for main site and another for virtual application.
then you can attach to a running process on your local machine.
you can start your two webapp in one port, and you can debug them.
There must be a better way to update links inside the layout/master page when publishing, I need to do this since I host my static contents in CDN and it should be linked differently since I have a shared CDN folder between many applications for some static contents and another part is only used by the app. that are used than on local machines. I don't want a to put server code to test anything as its useless to add code that test that on production, I was thinking is there a way to make layout pages like web.config where you create one file with debug added to layout name which will be picked locally while the release one is the one that get published.
performance is very important to me and i do no want any extra call that can be eliminated.
I don't want to be running a code that never be needed when you move the app to production.
Basically i hope there is a way to publish a different version of the layout page that point to the correct static contents since this will be the best way performance wise, MSBUILD should have that but i can not find the info.
Do you means static file like Javascript,Css & Images.
In your MVC app just make a global variable called CDN_Path. Define the appsetting in web.config so you can define the CDN path through web.config.
use this variable like this
#(Globals.Root_Path)Images/Test.png
Now anytime you move your CDN from Amazon S3 to somewhere else you can use it without any headache. Just change the value in web.config (when you change CDN) make it work everywhere in your site.
I hope I'm asking this question in the right place. I also asked on umbraco forum, but did not get any response yet.
I'm having problem with deploying my Umbraco 5 website to external hosting.
On local machine, I used Umbraco 5 template for VS2010, which works fine (although it's quite slow).
When I publish to live server I get 500 error.
So far, i've tried installing fresh copy of umbraco on hosting (works fine).
I copied config files in hive provider folder (in App_Data), to point umbraco to my hosting database. That does not throw any exceptions yet. Problem starts when I copy views and partial views over - umbraco then finds the template defined in database and tries to load that.
It's worth mentioning that I also copied my project.dll file into bin directory on the server - the reason for that is because I have added new controller which inherits from surfacecontroller (in /Controllers folder).
Please let me know if I'm doing something wrong.
Cheers
Sebastian
It is not any different than deploying a MVC3 website.
There are quite a few questions with exactly that signature here on so.
Visual studio even has a few tools to help you in the process.
The publish function is found right clicking the project in the solution explorer.
If you use the template for developing, you have a working umbraco solution locally right?
If that is the case, it is easier to just deploy / publish the entire site intead of copying bits into another umbraco solution.
Publish tool
When using that tool, remember that umbraco has quite a few config files etc. and they all need to be included. So it is probably the easiest to just export all files in the folders, by changing "which files to include" setting in publish tool. That will unfortunately include all your .cs files too, but later they can be filtered out of the publish process.
First make it work, then make it awesome :)
The same goes for compilation mode, i have found that release mode sometimes breaks things, so for now just keep it in debug mode.
Then later when you have it working, you can change to release mode for a small performance gain.
Stuff to remember
include all necessary files
change connectionstrings
copy databases
custom errors, you don't want your visitors to see YSOD's with your internal debugging info.
disable tracing and debugging!
After reading this, you should go on and look for other more elaborative resources too.
"umbraco then finds the template defined in database and tries to load that" is key point to me
whatever the version you follow the templates and doc types are the backbones of umbraco ( from you website I know that you are aware with above more then me.. but repeating.) I mean you have created new website but there are no relative Templates and Doctype yet you try to use them in views and subviews and that caused the problem.
To do that please create tempalte and doctype same as is in you staging site and this problem will be solved.
Even better kick-start you development with new site only and make replica of that after defining doc-type and templates to your staging.
I hope i can explain my point.
Thanks,
Jigar
I've had problems in the past deploying Umbraco 5 projects. When you deploy an Umbraco 5 website to a new server and before you switch the website on in IIS, navigate to \App_Data\ClientDependency and delete any XML files that are there. Next, navigate to \App_Data\Umbraco\HiveConfig and delete the ConfigurationCache-*.bin files.
Once you've done that, recycle your Application Pool and start your website.
I want to be able to have a folder which allows regular access like the \content folder except that it holds a ClickOnce application. I can't seem to be able to achieve this using Mvc, but I'd like to have this folder accessible without Mvc seeing it as a controller action.
I tried using routes.Ignore(theUrl), but this seemed to have no effect.
There are two ways you can do this. The first is where you are currently going, which is to satisfy it with routing. You should be able to use the following to ignore the intended route:
routes.IgnoreRoute("...")
However, this might not be the right approach from a security stand point. I would recommend you define an explicit action to download your click-once exe. Have a look at this q/a as an example of using the FileContentResult class.
The reason for this is that you can control security for that file without having to open up access levels to other directories.
Edit: If this is for an entire directory, you can still follow this same approach.
Set up the folder as a virtual folder in the website on IIS. then you can set the url in the code to point to the machine serving the request and to the virtual folder on the web server.
I've created a basic website using the Orchard CMS, and attempted to deploy it to my shared host, Softsys, using Web Matrix (via FTP). Currently, the site technically "works", however it looks like all styling has been removed (even from the dashboard).
Is there a step or files that I missed while deploying the site? I know "Web Deploy" is probably the preferred method of deploying, but I'm pretty new to this, and was not sure what the login specifics were, or how to obtain them for web deploy.
Here is a screenshot of what the site currently looks like deployed:
Edit: it turns out that the problem was on my host's side, for some reason the virtual directory was not being created properly - I still am curious what the proper/best practice method to deploying is however.
It looks like you have no theme applied. Check whether you have your theme existing in ~/Themes folder and properly enabled in the admin Dashboard. Maybe the /Themes folder content hasn't been copied?
UPDATE
If your hosting provider allows the option to deploy sites via WebDeploy - that would be the best one.
The easiest and most straightforward way to deploy Orchard site is to:
Have the ASP.NET application properly configured in IIS and accessible. If you use hosting - provider does that for you. If you'd have a dedicated server - you have to set up an application yourself.
Grab the deployment package from Codeplex, or build one from the sources.
Copy the whole package to your site's root (via FTP or WebDeploy).
Run it and proceed with the setup.
Basically - these are the same steps as for every "ordinary" ASP.NET application.
You probably need to set IIS user to have write access to some of the folders: Themes, Media and App_Data.