Reputation: 5128
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.
Upvotes: 0
Views: 172
Reputation: 2306
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
Upvotes: 1
Reputation: 1006
Check out ASP.NET Web Pages, WebMatrix, and the new Razor syntax, sounds like what you're looking for:
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.
Upvotes: 1
Reputation: 17196
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;
}
}
}
}
Upvotes: 0