Help with getting started building an ASP.NET website using VS2010 - c#

Ok, I want to build a web site using ASP.Net. My web development skills are very small. However I have used C# a fair bit for some fairly intermediate level work (lists, dictionaries, custom classes etc)
The site I want to build will run on an intranet, and I'll be using the AD to get the current users information.
This information will be cross checked with an MS SQL 2008 database (that already exists on the network) to determine what links they can see.
Other parts of the site will allow the User Table to be viewed and modified if the current user is an admin, and have new users added.
So, what is the best way to do this? I've done some playing and basically confused myself with all the options available..
For example, I can create a New Project, which gives me options like Web Application, MVC2 Web App, MVC3 Web App, Empty Web App, Dynamic Data Entities Web App, Data Linq to SQL Web App, and then some Server controls.
But then I can also go for the New Web Site, which has Web Site, Web Site (Razor), Empty Web Site, Dynamic Data Entities Web Site, Dynamic Data Linq Web Site..
There are too many options!?!?!? And I don't understand what the difference is between them all..
What do people suggest I use?

Have you tried following some of the MSDN Beginner Developer Learning Center stuff? They have a module on Beginning Website Development.

May be I am not answering to the point, but my 2cents. Why don't you go for Sharepoint development in this case. You can use Sharepoint site (having inbuilt AD support too) and develop custom webparts (like the part which queries SQL Server 2008). The advantage of using this is that you can merge the feature in intranet site (if you got one already using Sharepoint), and you can learn new stuffs too. Even it will be quick one and if in future, you want to use the Intranet site for different things, it's easily extensible with minimal fuss.

There are some good tutorials for MVC here http://www.asp.net/mvc.
I suggest if you are building a web site to use MVC as it seems like the latest and greatest from MS at this time. My personal opinion tho.
You would want to just start with New Project.

Ok, this is a lot of things to look at and there a are a few ways to tackle this. First all all just stick to New Web Site for now.
First things is to know if this is an intranet or internet?
it seems like it since you want to use AD, that it is an internal app.
Although there are many ways to accomplish what you are trying to do. I Think the following would be the easiest to implement.
1) Enable digest authentication
2) Set a IE group policy to the User authentication policy to Automatically logon only to intranet - This way people dont get confused to what they enter.
3) Create groups for each type of user in AD
4) Separate each functionality into different folders.
5) Set the web.config for permissons to the appororiate directories.

#Matt provided a link to a useful video ("Choosing the right programming model"). In it, Microsoft's Scott Hanselman describes the distinguishing characteristics of the three primary ASP paths: ASP.NET Web Forms, ASP.NET MVC, or ASP.NET Web Pages. Here's the main bullet points from that presentation:
ASP.NET Web Forms:
Familiar control- and event-based programming model
Controls encapsulate HTML, JS and CSS
Rich UI controls included - datagrids, charts, AJAX (common tasks available out-of-the-box)
Browser differences handled for you
SharePoint builds on Web Forms (so, useful if you want to be a SharePoint dev)
ASP.NET MVC:
Feels comfortable for many traditional web developers
Total control of HTML markup (controls not provided; good grasp of HTML required)
Supports Unit testing, TDD and Agile methodologies
Encourages more prescriptive applications
Extremely flexible and extensible
ASP.NET Web Pages:
Easy to pick up and learn (similar to PHP or classic ASP)
Inline scripting model with Razor and C# or VB.NET
Simplified model with Top-to-bottom execution
Full control over your HTML
Friendly Helper syntax (encapsulated functionality, similar to Web Forms controls) makes extending your apps easy
All these models are built on common ASP libraries, so there is considerable overlap, and a fairly straightforward path to migrate an app from one model to another.

Related

How do I integrate a new MVC C# Project with an existing Web Forms VB.NET Web Application Project?

We have a corporate website with a large amount of dynamic business application pages (e.g. Shopping Cart, Helpdesk, Product/Service management, Reporting, etc.) The site was built as an ASP.Net Web Application Project (WAP). Our systems have evolved over the years to use .NET 4.5 and various custom business logic DLLs (written in a mix of C# and VB.NET). However, the site itself is still using VB.NET Web Forms. We now have done a few side projects in MVC 4 using Razor/C#, and we want to use this framework for new pages on the main corporate site going forward. What would be the easiest way to achieve this?
I found this nice list of steps to integrate MVC 4 into an existing Web Forms app. The problem is that because our existing app is a VB.NET WAP, it compiles into a single DLL, and .NET allows only one language per DLL. The site is way too big for us to contemplate converting it to C# all at once (yes, I've looked at the conversion tools, and they're good, but even 99% accuracy would leave us a huge amount of cleanup work.)
I thought about converting the existing WAP into a Web Site Project (WSP) which does allow mixing languages and then following the steps above, but after a few pages of Google results, I couldn't find any steps for converting a WAP to WSP. (Plenty of sites offer the reverse steps: converting a WSP to a WAP.)
Another idea I had was to create a completely separate MVC project, and then somehow squish them together into the same folder structure, where they would share the bin folder but compile to separate DLL's. I have no idea if this is possible, because certain files would collide (e.g. Global.asax, web.config, etc.)
Finally, I can imagine a compromise solution where we keep all the MVC stuff in its own separate application under a subfolder of the main solution. We already use our own custom session state solution, so it wouldn't be difficult to pass data between the old site to the new pages.
Which of the ideas above do you think makes the most sense for us? Is there another solution that I'm missing?
After some more research and experimentation (and thanks to a suggestion from T.S.) I have narrowed it down to either the 2nd or 4th option from my initial question:
Convert our WAP to a WSP, and then follow the steps to integrate MVC into the site. I don't see moving from a WAP to a WSP as a complete step backward. As the MSDN link explains, performance does not suffer, and it's mainly a question of how to adjust our build/deployment process. The major advantage with this technique is that it allows multiple languages to coexist in the same project and root folder. Certain files, such as Global.aspx.vb, would have to remain in VB.NET. But specific folders and web pages could be designated as C#. The disadvantage for us is that our site has a lot of legacy pages that use old-style server-side-includes of ASPX page fragmets, and these cause build errors in a WSP. These would have to be changed into User Controls, or perhaps renamed to an unrecognized extension, such as .aspxinclude, so that they are not included in builds.
Create an MVC child application as a new .NET project (see http://support.microsoft.com/kb/307467). The parent web.config needs its <system.web> section wrapped with <location path="." inheritInChildApplications="false">, and the new app's subfolder needs to be converted to an Application via IIS Manager. The child app can be a WAP using a different default language (C# vs VB.NET). This makes it is easier to isolate from our existing project. But this is also a disadvantage because the MVC routing only works on URL's in the subfolder of the child application. So if we wanted multiple parts of our site to use MVC routing, it would require separate child projects, e.g. (/cart, /myaccount, etc.)
We are probably going to go down the path of option #1, converting to a WSP, and only resort to #2 if we encounter a big obstacle.
UPDATE: I was able to do the conversion using technique #1. It's been working for several months now, so I published a blog post with the procedure I followed.
Came up with a very simple solution.
Create new MVC C# project
Add the old vb project to the solution.
Move the VB aspx pages to the new C# project
REMOVE THE CODE BEHIND ATTRIBUTE FROM THE FIRST LINE OF THE VB PAGES eg...Codebehind="ProductDetails.aspx.vb" (this is the magic)
Add a reference to the VB project in the C# project
This will work for master pages as well
Strangely the VB aspx pages 'just find' the codebehind from the reference and the C# project does not seem to care about the aspx pages being VB.
Go figure!
Hope I saved someone some time. I spent many hours on this.
You have 3 options here:
Convert the ASP.NET Web forms from VB to C#
Convert your MVC 4 written in C# to VB.
Develop all old apps in ASP.NET Web forms again to MVC 4 (ugly but better for future changes)
My advise is keep them diferent projects only share your business logic. And in the same solution file.

Simplified "Razor-Only" website?

I have a website I want to make using the Razor template engine, however it really only has one simple page with a basic AJAX form in it. Having a full-blown MVC Web Application seems like a massive overkill for this, but I don't want to have to use something like PHP. Can I use Razor in a 'PHP-like' manner (i.e. one or two .cshtml/.vbhtml pages I can make requests to, in a similar function to how you make requests to .php pages)?
This will be hosted on IIS 8, if that'll help.
You can use razor with ASP.NET Websites (not web projects).
To do this go to File > New Web Site... and pick one of the templates that supports razor.
http://msdn.microsoft.com/en-us/library/gg606533%28v=vs.100%29.aspx
Gives more depth, however, you might be able to skip the first step "Installing the ASP.NET Razor Tools" if you already have it installed.

Can you use the CMS Orchard along side your own ASP.NET website?

I have a ASP.NET website which has various utility scripts/pages for some software but no public website. I would like to use Microsoft's Orchard CMS to create the website for visitors to look at - but would this mean I would have to move the utility scripts?
Can you run ASP.NET pages etc alongside Orchard or do you have to extend Orchard to do those tasks for you? If you can run scripts alongside, is there anything you should do to prevent interference with Orchard?
I will accept an answer from someone who has experience with Orchard or good reasoning.
Thanks in advance!
If you're speaking about existing ASP.NET WebForms application then I guess no, at least it won't be easy.
In this case your best bet would be to either
run those applications separately with appropriate rewrite rules, so for end-user it would look like a single application. With this approach you won't be able to access Orchard features (like user management) from your exisiting app, though.
rewrite your current pages to MVC and move those along with existing utility scripts to a separate Orchard module
If you're speaking about existing ASP.NET MVC application - the solution could be found here.

Merge sitecore project with another .net project

I have a unique requirement which I need to meet to with sitecore, and I was wondering if it is feasible. The client has an existing .net solution, which is a web project (web site, not web application) that is built on the spring framework and commerce server. They now want to use sitecore to enable content editing on 'some' of their pages. THe requirement is that they do not want to maintain the master pages and any common items in sitecore, but they want sitecore to be able to use the master pages and all the controls they have in their custom solution. I've checked through their project, and they have a LOT of dependencies on many other references and projects, and so it is not a fairly simple application. They do not want to have the master pages specifically in sitecore, and they only want sitecore for the main content editing. They basically want all the layouts in sitecore to use their master pages. I've tried using virtual directories and then using the master pages in sitecore, but there are way too many dependencies in their project. I've tried to make sitecore an application within its own directory, but it doesn't seem to work very well. I can merge the web.configs as much as I can, but that is going to cause headaches down the road when its time to upgrade...My more high level question is, is this doable at all, and if there is a way I can meet this requirement.
Initial thoughts are that using master pages within Sitecore is bit of a non-starter. It seems odd to have such requirements and have Sitecore already prescribed.
Three ideas come to mind.
1) Consider keeping the solutions separate, and host certain Sitecore pages in a clean, standard, Sitecore solution. Use a load balancer to direct which urls point where. There could be many side effects to this approach to do with sessions etc.
2) Migrate the existing solution to Sitecore replacing master pages with Sitecore layouts and sublayouts. At the same time, migrate to a web application project. This is very likely the best long term approach. The main challenge would be mapping existing content to a set of templates in Sitecore, and various bits of refactoring.
3) Use Sitecore as a content repository, but serve content from your existing web site solution. This will have numerous complicating factors due to lack of a typical Sitecore item, site & domain context which would all need to be handled by custom code. The solutions could be entirely separate, and even use web services to retrieve content from Sitecore which is served by the existing solution. It gives full separation, but you loose a large chunk of Sitecore functionality and end up with an expensive rich text editor + database.
I'd opt for #2 where possible.
I think I can see a few options on how to do this. I'm currently doing something similar right now on a large enterprise project where there's an existing ASP.NET MVC application running the bulk of the site. Here are some options I can think of:
Use a sub-domain for the Sitecore-only stuff and <iframe> in the Sitecore content or do an HTTP GET to the Sitecore pages and pull the content into the existing app. E.g. sc.mysite.com is the Sitecore app. I'm currently doing this with MVC now and its fine. From a content management POV, editors can still use Page Edit mode on the Sitecore pages in their stand-alone state but the content is in production in the fed in state on the main MVC site.
Sitecore can use MasterPages, it just defeats the purpose of the presentation layer of Sitecore. Essentially, you can have your Sitecore layout inherit from the MasterPage and it works just like any normal application would with inheritance. I'm not sure of the caching implications though. As long as your app references the Sitecore assemblies, you can use the API as long as its part of the Sitecore context. If you DO use MasterPages with Sitecore, make sure you add a placeholder with the key webedit to allow page editor to work: <sc:placeholder key="webedit" runat="server" />

Sharepoint intranet portal

Migrating (rewriting) a whole portal originally made in .net to shareopoint doesn't seem like a very easy thing to do.
I've been assigned such task and now i'm just learning, planning and starting to get things practical in order to accomplish it faster.
It's not exactly a question, it should be a discussion about it and may help others who might get to do the same job further on.
1 - There's something like a "message board" in the current portal, which i'm planning on building with a blog site kind, what do you sugest?
2 - as asked in another question, i have to manage users, and the local active directory is organized and reliable, so i guess that's what i'm going to use
3 - There's got to be a way to store files, images, documents and having version controlling in some of them.
4 - There's got to be a customization in design and a cleaning in the default controls of sharepoint masterpage (which may be useless for the desired purposes)
5 - About 30 local users and being accessible from the internet (local server) in case our consultors have to access it from clients
6 - i have available a version of the Visual Studio 2010 (already with the graphical webpart designer) because the company i work is MS gold partner.
7 - I'm going to program webparts in c#, and the designing part is still a mistery to me, since i'm not that familiar to shareopint yet.
I'd like some tips, links and answers.. i'm going to be watching this question from now on and answering any other information.
1.) SharePoint 2007 has some blog/wiki/board functionality but it's very immature. I tried to get my team to use them but the user interface is lacking and it is challenging to enhance those elements. SP2010 might offer a better experience though.
2.) User management in SharePoint is easy to perform but difficult to manage. Establish processes for adding/modifying end users and keep the number of people with that ability to a minimum. Otherwise it gets out of control and you end up not knowing who has access to what. I would also suggest relying on AD groups as opposed to giving individuals specific access in sites.
3.) Document storage is SharePoint's forte, I think you'll be impressed.
4.) SharePoint branding will require some time but other people have it down to an art form. Note that some pages (referred to as Application pages) shouldn't be fully controlled. Also note that you don't want to remove controls from the master page as some functionality in SharePoint assumes the controls are there - rather it is better to hide them using CSS.
5.) This sounds like a bad idea. SharePoint exposed to the Internet is supposed to be severely locked down - but if you lock it down (i.e. remove access to Application pages), the functionality that you seek won't be available. Have you considered an intranet and separate extranet?
6.) Should be okay, VS2010 is supposed to be a better development experience with regards to SharePoint.
7.) Keep your branding and functionality separate and be sure to deploy them using solution files (as opposed to working directly with the file system). Also, never ever read/write the database directly.
I think you'll find that replacing a custom intranet with SharePoint is a common task but there will be a learning curve. The hard part will be branding and data migration. End users will reject the new system if it is slow - so be sure to get the architecture and configuration right before launch (might require a consultant).
1 - There's something like a "message
board" in the current portal, which
i'm planning on building with a blog
site kind, what do you sugest?
SharePoint discussions are perfect for what they are intended ... small targeted discussions. A forum is very different. It is a centralized area with multiple threads with different topics. You can try CodePlex (which is your friend)
SharePoint Forums
2 - as asked in another question, i
have to manage users, and the local
active directory is organized and
reliable, so i guess that's what i'm
going to use
AD is perfect if you already have it ... nice thing is that you can use the Profile page to update AD information which syncs ... you have a lot of capability with this. But, one of the main benefits is that SharePoint can support multiple authentications. You can extend a SharePoint site and plug in a different authentication (like SQL Auth) and then multiple sets of users can interact on the same sites with different permissions. Not to mention that SharePoint doesn't just provide site access but you can make security granular all the wat down to individual items in a list or library.
3 - There's got to be a way to store
files, images, documents and having
version controlling in some of them.
This is where SharePoint has the most capability OOB.
4 - There's got to be a customization
in design and a cleaning in the
default controls of sharepoint
masterpage (which may be useless for
the desired purposes)
We have a completely customized MasterPage complete with code behind. You need to know about Feature Stapling and Feature Receivers. Also use Heather Solomon's website
5 - About 30 local users and being
accessible from the internet (local
server) in case our consultors have to
access it from clients
SharePoint seems almost overkill for this number of users.
6 - i have available a version of the
Visual Studio 2010 (already with the
graphical webpart designer) because
the company i work is MS gold partner.
Get the Visual Studio Extensions for SharePoint
7 - I'm going to program webparts in
c#, and the designing part is still a
mistery to me, since i'm not that
familiar to shareopint yet.
Look into Application Pages instead of WebParts ... Application pages are way more flexible for custom forms than web parts. Web parts are only usefull for when functionality needs to be available on an ad hoc basis so that you can allow users to drag the functionality onto a page or if you need to restrict functionality to specific sets of users (since layout pages are available to all sites).
The answers to this person's similar but not identical question may be helpful: Sharepoint for a C# Asp.net Developer
There's a lot of help available in other existing SO questions. Just click on the "sharepoint" tag, then sort by votes, and you'll find a lot of interesting reading.
Regarding 7 - Programming web parts:
Have a look at SmartPart on CodePlex. This is a fairly easy way to create simple web parts especially if you have some ASP experience.

Categories