0

I'm learning ASP.NET (slowly), trying to avoid WebForms entirely, but I'm finding MVC, ORMs, EF, and all the rest a little bit overwhelming. I am quite solid with HTML, HTTP, CSS, C# and the BCL.

I have a tiny bit of experience with PHP (ewww), but I've found it to have the deployment and convenience advantages for super small tasks.

I'd like to get a "quick start" where I can just one file in which I can manually connect to the database, run some sql and then loop over the result it to produce some HTML. Small amounts of Visual Studio magic are acceptable. ;)

Is there some sort of microframework or "basic project template" I've been missing?


This is similar to this question about doing the same thing with ruby.

4
  • You can do what you describe in an ASP.NET MVC View (and a whole boatload of other useful stuff in the rest of the framework), without suffering the madness of PHP. Commented Jul 6, 2012 at 0:45
  • Ok then, what's the best way of having a 'standalone' MVC view? Commented Jul 6, 2012 at 0:47
  • Why would you want to do that, when there's so much more happiness using the entire framework? You can scaffold an entire application in about 5 minutes, if expediency is the issue. Commented Jul 6, 2012 at 0:47
  • @RobertHarvey I understand your viewpoint, however: a) I don't want an entire application. b) It'll only takes 5 minutes once you know what you're doing, which I don't. c) It's interesting to know from a educational perspective. Commented Jul 6, 2012 at 3:50

3 Answers 3

1

Check out ASP.NET Web Pages, WebMatrix, and the new Razor syntax, sounds like what you're looking for:

http://www.asp.net/web-pages

I'd highly reccomend learning the MVC framework, but this should be a good start and will be relevant knowledge if/when you decide to go MVC.

Sign up to request clarification or add additional context in comments.

Comments

1

If you are too overwhelmed by MVC, EF, etc have a look at ASP.NET Webpages:

Its a good starting point and some of the stuff you learnt eg Razor can be applied to ASP.NET MVC

Comments

0

If you want to avoid WebForms all together, then you can use a Handler.

I can understand why you'd want to do this while your learning but remember WebForms are definately not the enemy.

<%@ WebHandler Language="C#" Class="MyNamespace.Handler" %>

using System.Web;
using System.Data.SqlClient;

namespace MyNamespace
{
    public class Handler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            context.Response.Write("<html><body>");
            string connectionString = ""; // todo: fill in your connection string
            int numThings;
            using (var connection = new SqlConnection(connectionString))
            using (var query = new SqlCommand("select count(*) from Lights", connection))
            {
                numThings = (int)query.ExecuteScalar();
            }
            context.Response.Write("<h1>There are {0} lights!</h1>");
            context.Response.Write("</body></html>");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

1 Comment

WebForms are not the enemy? From playing around with the designer all I see are terrible html, a ridiculous number of roundtrips and an insane amount of state[fulness]. I know there are ways to tame most of those things but why? (thanks for answering my perilous question though!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.