.NET Core vs .NET Framework Web Applications in ASP.NET

“When and when not use .NET core and .NET Framework”

When you gone to create new ASP.NET web application you will get many templates if you selected new .NET framework version and with new VisualStudio versions. This is little confusing for anyone when first seeing this. But as for Microsoft; one for fully Microsoft platform support and other one for cross platform support.

Will check; what’s best option which we can select with our requirement as below;

.NET Framework .NET Core
Better to run on Windows Better to run on any platform ie. Linux, Mac..etc
Superior Subset of framework
Deployable mostly only to Windows Deployable to any platform
Mostly not Involve command line style development
Mostly sticked to VisualStudio May use different development environments such as VS code, Sublime or anyother
App migration or development involved for other environments No involvement required in most of the cases
All .NET sub frameworks supported Sub-frameworks like WPF, WindowsForms, WebForms..not supported

Useful references

https://docs.asp.net/en/latest/fundamentals/choosing-the-right-dotnet.html

Advertisements

View actual error in SharePoint without ‘something went wrong’ (Enable debug mode in SharePoint)

Go to your SharePoint web.config file and open it with admin privileges in a text editor.

<local file location>\inetpub\wwwroot\wss\VirtualDirectories\<SharePoint Web App>\web.config

Eg.

C:\inetpub\wwwroot\wss\VirtualDirectories\8888\web.config

Make your compilation debug mode true

Make your Call stack true.

 

CustomErrors mode to off

 

Finally you will be able to view the actual error without customizing it in debug mode;

Note:

It’s better if you keep a backup on above file before make any change.

 

Simple MVC project

simple mvc

MODELS


[1] CREATE USER MODEL
—————————–
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace _1___kushan.Models
{
public class User
{
public int ID { get; set; }
public string Name { get; set; }
}
}

[2] CREATE DB CONTEXT
———————

namespace _1___kushan.Models
{
public class Context : DbContext
{
public DbSet<Models.User> Users { get; set; }
}
}

CONTROLLER


[3] CREATE CONTROLLER
———————

using _1___kushan.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace _1___kushan.Controllers
{
public class UserController : Controller
{
//
// GET: /User/

public ActionResult Index()
{

return View();
}

//RESPONSE FOR SIMPLE BUTTON CLICK
[HttpPost]
public ActionResult Index(Models.User user)
{
Context con = new Context();//object with context
User u = new User//user model
{
Name = user.Name
};
con.Users.Add(u);//adding
con.SaveChanges();//writes to DB
return View();
}

}
}

VIEW


[4] GENERATE THE VIEW USING SCAFFOLDING
—————————————————–

@model _1___kushan.Models.User

@{
ViewBag.Title = “Index”;
}

<h2>Index</h2>

@using (Html.BeginForm(“Index”,”User”)) { <%–mention action & controller –%>
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)

<fieldset>
<legend>User</legend>

<div class=”editor-label”>
@Html.LabelFor(model => model.Name)
</div>
<div class=”editor-field”>
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>

<p>
<input type=”submit” value=”Create” />
</p>
</fieldset>
}

<div>
@Html.ActionLink(“Back to List”, “Index”)
</div>

@section Scripts {
@Scripts.Render(“~/bundles/jqueryval”)
}

Simplest way to send email from your C# (ASP.net) application

<1> IMPORT LIBRARIES >> TO FORM(or ASPX page ) & CLASS 

using System.Net.Mail;

<2>INCLUDE CLASS BELOW 

class sendmail
{
public void testmail(string to,string subject,string body)
{
try
{
string To=to;
string sub=subject ;
string Body=body ;
MailMessage mail = new MailMessage();

SmtpClient SmtpServer = new SmtpClient(“smtp.gmail.com”);

mail.From = new MailAddress(“absccd@gmail.com”);

// email adress that i have created on gmail

// or you can use any mail server such as yahoo,aol,msn,and so on

mail.To.Add(To);

mail.Subject = sub;

mail.Body = Body;

SmtpServer.Port = 587;

SmtpServer.Credentials = new System.Net.NetworkCredential(“userNAme”, “Password”);

//enter uname and pwd of email address you want to send email from

SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);

MessageBox.Show(“mail Sent successfully”);

}

catch (Exception ex)
{

MessageBox.Show(ex.ToString());

}

}

}

<3>CREATE OBJECTS FROM THAT(in the form or page) and USE IT

sendmail obj = new sendmail();
obj.testmail(toContentTextBox.Text, subjectContentTextBox.Text, messageContentTextBox.Text);

 

//enjoy your program