Where is MVC3's App_Code folder - helper

This post contains a nicely succinct explanation for implementing razor helpers. But it refers to the use of the 'App_Code' folder - something i can't get my MVC3-transitioned-from-MVC2 project to create. I understand this has to do with WebSite vs. Web App but to be honest - i can't remember if the original creation was site or app. Since there's menu selection 'Convert to Web Application' seems it was created as a Web Site. But then there should be a App_Code dir, yes?
Attempting to recreate the steps from the original post (within a manually created 'App_Code' folder) presents pre-compile errors (MyHelpers does not exist in this context) - but the strategy _does work. - at least the simple hello stuff did. so i shouldn't argue with success? MVC3/Razor isn't fully intellisensed yet?
thx

I created an app_code directory by just creating a folder called app_code. MVC3 dealt with this file correctly by creating static methods for the code I put in there. When I reopened my solution later, the app_code file had disappeared. I eventually found that the app_code file was marked as a hidden folder by visual studio.
In this virtual machine I have the RTM VS 2010. not sure if this was fixed in SP1.

Related

Visual Studio 2015 MVC Project Template Access Denied

I've created a very simple MVC application in VS2015 which has some basic CSS styling and some HTML to get an application off the ground more quickly.
The application runs perfectly.
I've exported this as a template using File -> Export Template...
I then created a brand new project based off this project type. So far so good. But, now when I run the newly created project I get a blank page with "Access Denied" (see image).
I've been going over the template project and the new project with a fine tooth comb and I can't find any differences. Why would one work but the other give an access denied? I am out of ideas, any help is appreciated.
EDIT:
After more research I have found the cause of the problem, but not a solution.
It seems that the project template has "Anonymous Authentication" as Disabled, and has "Windows Authentication" set to Enabled in the project settings. However when I create a project based on the template these values are flipped and thus causes the Access Denied.
Here's an image of the project settings in the template:
Here's an image of the project settings in the "new" project:
Note that both Authentication settings are flipped. Can anyone tell me how to get this to not happen?
Edit 2:
As suggested, the applicationhost.config files are different which is causing the above problem. Here is the applicationhost.config security section of the Template:
However, here is the same file in the new project created based off the template:
Notice that the section is missing entirely from the new project. So, now the question becomes how do you get this to copy over to new projects?
As suggested by BrianLegg I move my comments to an answer
Seems that the problem is related with the applicationhost.config file. This files it's not present on the zip file which contains the template.
You could take a look on the physical path attribute on
<system.applicationHost>
<sites>
Maybe it's trying to access to the first project instead the new one.
Could you check what is in your applicationHost.config template?
Take a look on Where is the template for applicationHost.config file stored
have you had a look at the global routes? it could be something routes not created or corrupted?

Create Web Deployment zip file from TFS build

Using TFS 2010 and I have a build project consisting of 2 solutions. One is a MVC solution with web pages the other is a solution containing multiple projects. These are various WFC services. I have added the criteria to publish each project in both solutions.
If I build either of them from VS - I get the zip files created.
If I use msbuild from a command prompt and build the WFC solution - I get the zip files.
Same for the MVC.
I then have a build project that builds both solutions, and I have as parameters
/p:DeployOnBuild=true;DeployTarget=Package
When I submit that build - it completes. But in the "_PublishedWebsites" folder I only get a package for the MVC project.
I've tried a LOT of variations but can't get the WFC solution to create the packages for the projects. I even named the pubxml files the same in each WFC project and tried passing that in as another parameter but the same results - MVC is correct; nothing for the WFC.
Even tried changes to Debug|AnyCPU versus Debug|Any CPU (space added).
I am thinking I have some little thing off that is biting me - but I can't find it.
Appreciate any assistance!
The WCF projects need to have been created as Web Applications and not just Websites. The default behavior you want is only available in Web Application.
There is walkthough on how to do the conversion on MSDN (http://msdn.microsoft.com/en-us/library/aa983476(v=vs.90).aspx). I tend to modify the documentation to be an in place upgrade by creating a blank web application and copying the project file over the top of the existing location.
You can then open that new project in VS (giving you two views of the same thing) and then adding the hidden files. Once working you can then delete the WebSite project and you will be left with thebWeb Application that will output to _PublishedWebsites.

Building application in Visual Studio 2012 always generates unwanted dll

I am making changes to a web forms application in visual studio 2012 and part of that change is to remove reference to an old dll. The dll is responsible for handling authentication and I have written a new class library to handle this.
My problem is everytime I build my website in the solution, it always generates this old dll. I've annotated out all references to it in the entire application and it's not in the project dependencies of the solution.
If I exclude the unwanted dll, it just generates a new one. I am completely baffled by this. It's something I've not encountered before so I am not sure what else I can do.
I'm not sure what to post so if anyone can help then that would be great.
I had a similar problem (but it was with a persistent DB file being generated). I ended up having to go through the bin from the project file and editing it from there. Some files are 'hidden' from the project, and are either visible by
Make sure you are showing all files. There is a button at the top of
the Solution Explorer called "Show All Files". To see this button,
make sure that your project is selected in the solution explorer.
or by manually going through your project files.
EDIT
It can sometimes be hidden in the Global Assembly Cache (GAC) where it can reside indefinitely. http://msdn.microsoft.com/en-us/library/zykhfde0.aspx explains how to remove it (if it is indeed hiding there).
try this, remove the old project from your Solution.

Publishing a Web Application from VS2012 is wiping out user content

I'm attempting to use Web Deploy to Publish a Web Application.
I want Visual Studio to delete any files that no longer exist, so I've checked the "Remove additional files at destination" setting in my Publishing profile.
However, I want VS to ignore the /Content/uploads folder, as it contains contents that my users have uploaded. Naturally, the contents are different in my development site than they are in the live site.
Unfortunately, I have been unable to discover a way to make Visual Studio ignore this folder when publishing (it wants to delete all of the content, since it doesn't exist in the project).
Does anyone know of a way to exclude specific folders on the target site from being examined by Web Deploy?
I had a similar problem, wanting to keep some files in the deployment package even though they're not part of the project.
Try to create a custom MSBuild target for this, that works for me.
Here is a Getting Started MSBuild reference
Hope this helps.
All the best.
I was unable to find a suitable solution for this issue, so I've created my own:
https://pubsync.codeplex.com/
PubSync enables quick and reliable file syncing for publishing Visual Studio projects.

Missing dll when deploying ClickOnce

When I publish a ClickOnce application, one of the references that is included in one of my projects is missing.
If I go to my project's Properties -> Application Files, this missing reference is not even listed here.
My bin/Release folder has an .exe.manifest file, and I noticed it that it is also missing from here.
However, when I build the project, the DLL is in fact copied to my bin/Release folder.
How can I ensure it also deploys this required dependency?
I finally found a solution for this problem and I hope it will solve your problem to.
In my case, I'm editing an old application at work which have multiple projects, but the main project and it's back end project are the most important here.
The back end is added in the References section of the main project.
In the back end, a third party dll was imported, but this dll requires 2 other dlls.
So those 3 dlls were added in the References section of the back end project.
At that point, one of the 2 other dlls was not showing in the Application Files section for ClickOnce.
I've come up with a couple of ways of fixing it, but the most elegant one was to add this dll in the Reference section of the main project.
As stated in How to: Specify Which Files Are Published by ClickOnce, change the Copy Local property value on the reference to True.
References to assemblies (.dll files) are designated as follows when you add the reference: If Copy Local is False, it is marked by default as a prerequisite assembly (Prerequisite (Auto)) that must be present in the GAC before the application is installed. If Copy Local is True, the assembly is marked by default as an application assembly (Include (Auto)) and will be copied into the application folder at installation. A COM reference will appear in the Application Files dialog box (as an .ocx file) only if its Isolated property is set to True. By default, it will be included.
I know is this an old question, but for anybody having similar issues. I think this is a cleaner way around the problem.
I had a similar issue and everything I did to get ClickOnce to deploy with the offending .dll failed.
Eventually, I had to deploy manually.
See walk-through here.
That worked for perfectly for me. But, for the life of me, I still wonder why that process can't be added to VS (I'm using 2017 community).

Resources