Is there a way I can get a blank MVC template for VS2008? Like the only that comes with MVC is nice to see what MVC is all about but it gets annoying when you want to make your own site and you first have to delete all the crap they generated for you.
Like I want to use my own authentication stuff since I understand what is going on and my own style sheets and stuff.
So I have to do through and delete everything ever single time so I wondering does anyone know of a template I can get that just has the basic structure of mvc and the bare minimum of stuff needed in the web.config file.
I don't know of any currently available, but at the least you can create the template you want by creating a custom Visual Studio Template.
Essentially, after deleting all of the files you don't want, do a File | Export Template in Visual Studio, follow the wizard to the promised land.
If you end up doing that, I am sure others would love to have it. I have just been too lazy to do it myself, and haven't really been creating a lot of new MVC projects, just working on the same one for months. :)
UPDATE: To respond to your comment: Although I haven't really looked too deeply into it, I don't know why you wouldn't be able to include in your project template access to the test project wizard. I cracked open the default ASP.NET MVC project template metadata file and found this near the bottom:
<WizardExtension>
<Assembly>Microsoft.VisualStudio.Web.Extensions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Assembly>
<FullClassName>Microsoft.VisualStudio.Web.Mvc.TemplateWizard</FullClassName>
</WizardExtension>
If they can do it, I don't know why you wouldn't be able to as well. I am interested in looking into this more, but at the moment I am heading to bed - I am already up WAY too late considering I have a horrible chest cold. :)
This is the way you can create your own template. I'm quite sure there exists one already somewhere, but if it's not - just bake your own. Shouldn't be so hard.
Related
I have a significant webform project that needs MVC4 integrated into it. MVC controllers etc.. are working fine. However i am not getting the MVC type context menu items e.g. add view when right click a controller method (see below - this is the add view that I want to see. It is missing from my project).
I have tried creating a blank MVC project then swapping out the web form csproj file for this and readding in all the webform elements but it broke the site in all manner of ways that i don't have time to resolve. I really don't want to go down this rabbit hole in any case - i suspect it's the wrong approach.
I have tried adding in (what i believe to be) the correct projecttype guid into the csprojj file by editing with a text editor i.e.
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};
{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
becomes
<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};
{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
but i still do not get the correct context menu items.
Can anyone tell me what I am missing?
Many Thanks for all help
Edit
This link gives an example for MVC3 and gives an idea of what I am trying to achieve. But the project type guid crashes the site (because it is MVC3) and my own efforts aren't working
http://www.britishdeveloper.co.uk/2011/05/convert-web-forms-mvc3-how-to.html
Further details i think are probably irrelevant
The project is an install of EPiServer Relate+ 7. A new site is starting from this but the majority of the site itself will be MVC (i hope). But we will use the re-existing web form elements for community type pages. There is no time or budget to convert these.
I don't think this is relevant to the solution. I think the problem is generic rather than particular to EPiServer.
Embarrassing!!!
I nearly got this right. I just needed to restart Visual Studio when I changed the project type Guid
So - the project type Guid for MVC4 is
{E3E379DF-F4C6-4180-9B81-6769533ABE47};
and the full element is
<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};
{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
BUT - don't forget to restart Visual Studio (Doh!!!)
I'll keep this question up in case others have got the same problem
Thanks for everyone's time
we are in process of switching our ASP.Net development from Visual Studio 2003 and .Net 1.1 to Visual Studio 2010 and .Net 3.5. So far, we successfully migrated our back end code and after some fight the ASP.Net front end code too. While the work on the back end code resumed with usual productivity, working on the ASP.Net front end code is massively hampered because of following issues:
The Visual Studio 2010 Web Designer crashes frequently (e. g. after using the "Undo" function) - we are used to the stability problems of Visual Studio 2003 Web Designer when working with large web forms, but the new Web Designer crashes frequently even with trivial web forms. Is there anything to make the thing stable? ServicePack 1 brought no help.
When adding new controls to a webform in the web designer, the declaration of the new control will never automatically propagate to the code behind page in the migrated web form. New web forms created from scratch seem to work ok. The migrated web forms maintain the old file structure (aspx, aspx.cs and aspx.resx), while the new web forms get a new file structure (aspx, aspx.cs and aspx.designer.cs. Recreating all the existing web forms manually to get the new file structure would be a very painful operation. Is there a way to make the old decent working propagation of controls' declaration to code behind file work in Visual Studio 2010 too?
(Currently our biggest problem): when designing a web form, we basically put the textboxes, labels, buttons etc. in a div with ms_positioning="GridLayout". We define absolute coordinates for every control in the div. This doesnot seem to work properly in Visual Studio 2010. With a lot of effort we can somehow continue using this approach, but adding a new button or textbox to a web form means massive effort now. Without paying really much attention it can even result in overwritig of the css-classes-file (the Web Designer sometimes decides to write the coordinates not in the aspx file but in the css file). I read recently that using absolute coordinates to position stuff on a web page is a very bad and deprecated approach. I tend to believe it seeing how gruesome it has to be done in the new Visual Studio. But what is the correct way to create winforms-like web forms rapidly? (With rapidly I mean simple drag-drop-point-click way of designing stuff).
Thanks in advance for any help.
Best Regards
Erich Horak
I'll try to tackle this issue by issue:
Designer
Unfortunately, the new designer in Visual Studio 2010 has been plagued with issues. With 2010, the editor was completely revamped with WPF, which was supposed to make it faster, but thus far has seemed inferior to the previous editors. There are some improvements, but if I had an option to choose I would stick with the old editor, at least until the issues are worked out with the new one. It may not be any consolation, but you are not the only one feeling that pain.
Adding controls/new page file structure
Again, this is another situation where migration will prove painful. If I were to suggest an approach, I would copy paste the markup into newly created forms (created w/ VS 2010). The designer.cs file should register the controls. You might run into issues with event handler mappings, but hopefully it won't get in the way of the designer.cs file registering the controls. I know this is a painful prospect, but you have to keep in mind that you're moving up several versions.
Designer view & absolute positioning
While you're migrating the system, you might want to set the default view to source-view, so you can paste the HTML onto the page. You can do this by going to Tools > Options > HTML Designer > General. Honestly, in my opinion, the designer is really flaky and should be avoided. The HTML it produces really is horrible.
Using absolute coordinates to position elements on a page is a deprecated approach for sure, but if your goal at this point is to get your migration working, then don't worry about it for now. Eventually, it would be a good idea to refactor your HTML and CSS to use more modern techniques, but if the current code-base is browser-compatible, then leave it for now.
It may not seem like it at first, but if you can move away from the designer and use the source view, you won't regret it. It does take a little more time at first, but having control over the markup will end up saving you a lot of time in the long run. If the designer is allowed to run rampant throughout the system, it will screw things up. By using the source view, you have full control over everything that's happening, which will become a huge advantage. By leveraging new features like master pages, you can move just as quickly in the source-code view as in the designer view of 1.1. I started out with the designer-view myself in 1.1, but after switching to the source-view, I never looked back again. You really do make up the productivity in other ways.
I wish I could give you a "do this and everything will snap into place" kind of answer, but I think you're in for a painful conversion process. The good news is, once it's done you can start utilizing all of the new features that have come around in the past 8 years. ;)
I see no quick, drag & drop way of doing this. Things like GridLayout are deprecated; much easier in the long run to port the forms manually, cleaning up the markup as you go and using the code view of the forms instead of the design view. Also an opportunity to write clean, separate CSS rather than inline styles.
Post 1.1, you do not need to declare the form elements in the code-behind - the new partial classes obviate the need for that. So this is just one more thing that is different. I am actually working on a similar project right now; I availed of the new master classes which meant changing quite a bit anyway.
My honest advice is to suck it up and move on :)
I asked a similar question here:
Visual Studio Multi-Project Solution Options
I just finished installing SiteFinity 3.7 standard version on windows server 2008. Is there a way to entirely/partially import an already existing .NET project (ASP.NET) into SiteFinity with some minor changes in the code of course (may be by changinf a couple of xml files or something similar). I could only see an "export" under Administration->Tools section but no import. I am new to SiteFinity so a detailed help/guidance would be much appreciated.
Thanks.
I think you're on your own here. Sitefinity stores everything in a database so you'll have to programmatically convert the sitemap (read XML insert into database). Sitefinity does have an API that allows you to do this. You can for example create pages and add controls to that page.
Sitefinity uses MasterPages as templates so that's easy. You can also re-use any controls you have.
But, by the time you're done writing the conversion code, I think you'll find that you could have done it all by hand in less time. Unless this is a huge website you need to convert.
if you just need to import the pages you can add them as "external pages". this allows you to set permissions, page properties, and add it to you navigation/sitemap but of course doesn't let you edit the page inside of sitefinity. I did this with some sites that were developed seperately but needed to be in our sitemap.
You could also wrap the content and code into user controls, then add those to the page. We did this for an application that we built. the pages had to live inside of sitefinity, but the programming was already done, and needed to be in user controls. Once again you don't get to edit the content in sitefinity, but you get to keep your existing code.
Finally, if you used any kind of content management system, you can easily import stuff like news/events/etc via the various managers, it works something like:
var mgr = new ContentManager("News");
var content = new mgr.CreateItem("text/html");
content.SetMetaData("Title", importedItem.Title)
...
mgr.SaveContent(content);
this isn't EXACTLY the code but it's something similar; you can use the api documentation to learn more.
If it's plain text, then unfortunately yes, you'll have to manually copy this into sitefinity. It is a bit of work, I did this with our hundreds of pages, but in the end it's worth it to have the cms benefits.
hope this was helpful!
I'm developing second language support for the site. So I made duplicate .ascx and .aspx files for existing ascx.cs and aspx.cs
Most of the time everything works fine.. but suddenly I'm getting:
Type 'ctrl_xxx' exists both in 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\d072cc72\b9d5698b\App_Web_xdmblegv.dll', and in 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\d072cc72\b9d5698b\App_Web_gkptrzo2.dll' (translated from russian)
ctrl_xxx ctrl = (ctrl_xxx) LoadControl("xxx.ascx");
I have few such strings of code... and same error occurs with one of them. But WITHOUT any changes from me with those files. To fix thaat bug for some time I need to delete solution and website folder and reget them from SS. Maybe there is an issue with solution? Solution was converted from vs2005.
You shouldn't localize an asp.net site by duplicating pages or controls. You use, for example, language specific resource files that are referenced in the one page or control. Have a look at this for a start on how to localize asp.net websites.
I agree with #Joe R, copying code is not a good way to localize. You may feel like you have gone too far down this road to change your approach, but in the long run you will be much happier and more productive with a different solution.
At the minimum I would switch to a different approach for the rest of the localization, finish the project, and then go back later and convert what you have already done to the new method.
Take a look at the following:
Globalization and localization
demystified in ASP.NET 2.0
How
do you localize a database driven
website
If you need a quick fix for your problem, you'll need to give new names to all of the pages and controls you copied. The error comes from having two user controls with the same name (just like it says).
However, everyone else is correct in that you are going about this the wrong way. What happens when you need to change some code? It will cause extra maintenance because you need to make changes in two places. More than likely, you will forget one, and you'll end up wasting a lot of time. If you invest in using language resource files now, you'll save on headaches later. And, I'm not even mentioning the possibility of needing to add an additional language down the road.
Edit
Try the following if you still don't want to use language resource files.
Put the non-language specific code into a separate .cs file. Make sure it inherits from System.Web.UI.UserControl
In ASCX 1, make sure its ascx.cs class inherits from your class you created in step 1.
In ASCX 2, make sure its ascx.cs class inherits from your class you created in step 2.
I'm an ASP.NET web part novice. I've built a few simple ones using only a class that derived from WebPart and overriding the CreateChildControls method, but nothing really very substantial. My question is whether it's possible to have a web part that also takes advantage of a separate html/asp.net markup file that will help provide some structure to the web part's output. In the past I just created server controls and added them to the controls collection, but this seems like a silly way to try to create a non-trivial layout. Can I do this? Do I have to use an ascx user control or can I bypass that step? There are a lot of hello world tutorials on web parts out there, but none seem to go past the CreateChildControls override. Thanks!
Yes, there is. Go here to learn about templated web parts, and go here to see all of the info he has on WebParts. I used this technique back in 2004/2005 and it worked very well.
The links in the above answer are no longer working, but here is an alternative one:
http://www.a2zdotnet.com/View.aspx?Id=95
In VS 2010 we also have visual web parts, that I think do pretty much the same trick but it's wrapped in a project item. I've only seen this in the context of SharePoint so not sure how it works for ASP.NET projects. Here is an example:
http://msdn.microsoft.com/en-us/library/ff597539.aspx