I want to change the default project structure for a new mvc project. I have seen a webcast where Scott Guthrie does this but cannot find it. Has anyone tried this?
You can find ASP.NET MVC project templates under the following address:
%VSPath%\Common7\IDE\ProjectTemplates\CSharp\Web\1033\MvcWebApplicationProjectTemplatev2.0.cs.zip
Related
How to add an ASP.NET MVC project to an existing ASP.NET Web forms application. How to call MVC project page from existing website.
You can refer this step-by-step guide on how to do that.
Your question is similar to
Is it possible to host an asp.net MVC in the same folder as asp.net web forms app?
We were in the exact same situation as you and it's not as bad as you might think. Thanks to Nuget it's a fairly easy process that you can follow and Dave Paquette describes how to do it in his blog post
And once you've got Mvc up and running all you need to do to go from one to the other is to redirect to Mvc from webforms:
Response.Redirect("~/Controller/Action/")
You can also use the Mvc routing system to generate routes from within webforms as well:
System.Web.Mvc.UrlHelper url = new System.Web.Mvc.UrlHelper(HttpContexxt.Current.Request.requestContext)
Response.Redirect(url.Action("Action", "Controller"))
I'm developing a plugin based application using MEF and Asp.NET MVC 3 and I want to create a custom project template to give third party developers when creating new plugins for application.
I can easily export it as a project template but since the host is developed in ASP.NET MVC 3, It seems more logical to be inside new Asp.Net MVC 3 project dialog.
Any ideas?
After some digging and 'reflecting', I got a template to successfully show up in the dialog. Most of the credit goes to this post: Add custom viewengine to New project dialog?
The key to getting it working on my machine (64bit) was the registry path mentioned in the answer in that post. I also found via Reflector there is a SupportsHTML5 key too, if you need that.
Here is a screen shot of my template:
and here are the registry keys (there is also a title and description at the MyOwnTemplate node)
If you look up your template directory for Visual Studio, and check out the template:
MvcWebApplicationProjectTemplatev3.0.cs.zip
(VS Install dir)\Common7\IDE\ProjectTemplates\CSharp\Web\1033
The thing to look at here is this line:
<WizardExtension>
<Assembly>Microsoft.VisualStudio.Web.Mvc.3.0, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Assembly>
<FullClassName>Microsoft.VisualStudio.Web.Mvc.UserInterface.MvcTemplateWizard</FullClassName>
</WizardExtension>
So they have got a custom Wizard working here.
these questions look to be similar:
Blank Asp.net MVC template
How to write an MVC3 Project Template that will offer option Razor or .aspx views
Basically, they say the wizard isn't open source but you could potentially write your own custom wizard.
EDIT:
here are a couple of page that tell you how to create your own wizard:
http://msdn.microsoft.com/en-us/library/ms185301.aspx
http://www.codeproject.com/KB/system/create_VS_wizard.aspx
I just wrote a blog post that covers how to do this and provides a zip file and a batch file with an example.
http://haacked.com/archive/2011/06/06/creating-a-custom-asp-net-mvc-project-template.aspx
I'm trying to incorporate Ninject with my ASP.NET MVC 3 RC application.
From the tutorials I found, I'm supposed to set the ServiceLocator via
MvcServiceLocator.SetCurrent
in the Global.asax file, but I can't seem to find this in ASP.NET MVC 3 RC. Has this been changed to something else?
The design for this feature has changed. The following blog post should answer your questions: http://bradwilson.typepad.com/blog/2010/10/service-location-pt5-idependencyresolver.html
Is something like Url.Action<TController>(...) or Html.ActionLink<TController>(...) in MvcContrib?
I see the FluentHtml stuff for forms, but I don't see the same concept applied to urls.
This post on CodePlex said it was added, but I don't see it in the source anywhere. Any help would be great.
Edit:
Also, I have read this, but would like to know specifically about MvcContrib.
I think that is part of the Futures: "ASP.NET MVC Futures Assembly"
jeef3 is correct, it is part of the ASP.NET MVC Futures. Mvccontrib has a dependency on it, so if you are using that library you already have it in your project.
I followed the guidance in the Professional Asp.net 1.0 Wrox book for adding the MVC references to an exisiting web application and it works well except for the scaffolding options. When i right click a controller i do not get the scaffold view options that you get in a new asp.net mvc app. I am sure there is a .csproj hack that is needed to get the scaffold options but i can't find any references anywhere. Has anyone else run into this and found a solution?
Well google to the rescue. I found an answer at the following blog: http://wildermuth.com/Tag/ASP.NET+MVC
You need to edit the .csproj file and add to ProjectTypeGuids {603c0e0b-db56-11dc-be95-000d561079b0}. Order seems to matter. Originally i added to the end of the guid list and the project would not load and threw an unsupported error. I created an empty mvc site and looked at the guids and the guid above was listed 1st. So i added it to the beginning and everything worked fine.
Have you looked at how you register the data context in you Global.asax file?
This link may have more details that can help:
http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.metamodel.registercontext.aspx
and this:
http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.metamodel.aspx