I have successfully added a file, X.ashx and its components (.cs, and so forth) to a project.
The structure is like this:
Solution Z
Project Y
Folder Layouts
Subfolder also named Y
X.ashx
SO the website has an address http://generic/SitePages/Home.aspx for the main file
I would think that one would use something like
http://generic/Y/Layouts/Y/x.ashx as the URL
and I've tried various permutations,
but I cannot get it to work correctly.
Does anyone know how the folder structure maps to a URL?
I am using Visual Studio 2012 and this is for a SharePoint project.
Also, my particular project does NOT have a web.config due to the template used....
Does anyone know of a good downloadable project/template for this in VS2012. I've tried searching but most projects do not have such a template.
Thanks in advance!
assuming you deployed the .ashx file to the layouts folder in the 14 hive, then it should be this:
http://yourdomain/SitePages/_layouts/Y/x.ashx
or
http://yourdomain/_layouts/Y/x.ashx
The Layouts folder gets referenced as _layouts in the url
Related
I have a standard ASP.NET MVC application with Bootstrap. I moved the "Fonts" folder to "Content/Fonts". Inside the folder there are those glyphicons-halflings-regular files.
When I start the application I get a 404 browser error that the Fonts/glyphicons-halflings-regular.woff and glyphicons-halflings-regular.ttf file couldn't be found.
How do I configure my project so these files are found?
Solution was to update pathes in my bootstrap.css.
(See comments of original question)
Thx meep for your help.
One solution is to update paths in bootstrap.css. However, when you update Bootstrap, your changes will be lost. I'd recommend simply moving your stylesheet as well to keep the hierarchical structure found in the unmodified stylesheet.
For example, if you want to move your fonts in the Contents/Fonts folder (I always hate it being loose in the project root folder too haha), have your styles in the Content/Styles folder so that ../fonts/glyphicons-halflings-regular.woff (and so on) still references the correct folder.
I am playing with RazorGenerator.Mvc at the moment, the purpose is to create a modular framework for my MVC4 applications.
I have been following several tutorial found via Google, and my application does work fine.
But, I have a question that keep bugging me.
So, my solutions looks like this:
-CoreMVCProject
-MVCModuleA
-MVCModuleB
I managed the Modules Project to copy the generated assemblies into the bin folder of the CoreMVCProject, this works with no issue so far.
But, when I create a Plugins folder in the CoreMVCProject, the views from the modules cannot be read, it always give error that said the views cannot be found.
Though, I have also added codes to add the assemblies within the Plugins folder, like:
var fullPluginPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins");
foreach (var file in Directory.EnumerateFiles(fullPluginPath, "*.dll"))
PluginAssemblies.Add(Assembly.LoadFile(file));
PluginAssemblies.ForEach(BuildManager.AddReferencedAssembly);
The views from Modules still cannot be read, though the Controllers and other logics in the modules can be accessed and performed without any problem.
So, in summary, the problem is how to manage it so the views can be read normally even if the assemblies are not copied into the bin of the main MVC Project.
Any Suggestion ?
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.
My MVC .net Solution has 2 projects:
The actual web project
This is all my models, views, controllers, attributes, etc. Some of the controllers reference my Reporting project, which includes local (e.g. non-server reports) reports that use SSRS and PDF generation.
The Reporting Project
This includes code that will connect to a database and generate the reports. The project also includes a folder that has a bunch of report templates. The report templates are "embedded resources". I have confirmed that they show up in the bin folder of the MVC app when I deploy.
The problem is, when I call the reporting code from within a controller, IIS looks for the report file relative to IIS. In the report code, I might say to look at "report/confirmation.rdlc". This works fine in a console app, however once I deploy with IIS, that path ends up being "C:/program files(x86)/iis express/reports/confirmation.rdlc", which does not exist.
I have also tried "~/report/confirmation.rdlc" to the same result.
I am assuming this means that the home folder (~) is in fact the IIS Express root. How can I change that for the app?
Just try to use Server.MapPath("~/bin/reports/confirmation.rdlc") instead.
I see that ASP.NET MVC generates a Content folder by default, which stores the site.css file. I have a site that uses some image files and XML files in order to do its job, yet I do not want to have those files as embedded resources. Should I just put the files in the solution within the content folder? Should I turn off the "Do not copy" build option on each resource since I will need to deploy the files to the website? Or should these files not even live in the solution and be loaded from the file system?
It's a good approach to add all your files/resources to the solution (at least you can see them in VS ;-) Other developers won't be surprised that your solution really needs some other files.
If those files are the 'content' of your website (like css files) then you can store them in the Content folder. It is up to you what folder structure you come up with. For example you might want to store your images in folder related to the modules of your application, or just all in the images folder. MVC doesn't enforce any particular way of keeping your resource files.
Just leave the Build Action set to Content and Copy to Output Directory to 'Do not copy'.
You might want to take a look at T4MVC project (also available as NuGet package) which will help you in keeping urls to your images / files compile-time safe.