This sample allows you to highlight C# source code. Highlighting is based on http://hilite.me web service, which is called from a background job in a truly asynchronous way – neither controller, nor any other entity is waiting for a completion. Results are delivered via WebSockets using SignalR.

All the snippets are removed every day at 12:00 AM UTC.

using Hangfire;
using Application.Letters.Commands;
using MediatR;
using System.Threading.Tasks;
using System;

namespace Application.BackgroundTasks
{

public interface ILetterTreeAdvanceJob
{
}

    public class LetterTreeAdvanceJob : ILetterTreeAdvanceJob
    {
        // pu
        // public void AddTask()
        // {               
        //     RecurringJobManager.AddOrUpdate("lettergenjob",
        //         () => Mediator.Send(new AutoGenerate.Command(){UserId="System"}), 
        //         Cron.Daily(8, 10), null);
        // }

        private IMediator _mediator;

        public LetterTreeAdvanceJob(IMediator mediator)
        {
            this._mediator = mediator;
        }

        public async Task AdvanceTree(long fileId)
        {
            var ret = await _mediator.Send(new AdvanceLetterTree.Command(){UserId="System", FileId=fileId});
        }
    }
}
public ActionResult Index()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            //using (var clientContext = spContext.CreateUserClientContextForSPHost())
            using (var clientContext = new ClientContext(spContext.SPHostUrl))
            {
                clientContext.Credentials = new NetworkCredential("SPAdmin", "Adm+123", "CORP");

                if (clientContext != null)
                {
                    var spUser = clientContext.Web.CurrentUser;
                    clientContext.Load(spUser, user => user.Title);
                    clientContext.ExecuteQuery();
                    ViewBag.UserName = spUser.Title;
                }
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
using System;
using System.Linq;
using System.Web.Mvc;
using Hangfire.Highlighter.Models;

namespace Hangfire.Highlighter.Controllers
{
    public class HomeController : Controller
    {
        private readonly HighlighterDbContext _db = new HighlighterDbContext();

        public ActionResult Index()
        {
            return View(_db.CodeSnippets.ToList());
        }

        public ActionResult Details(int id)
        {
            var snippet = _db.CodeSnippets.Find(id);
            return View(snippet);
        }

        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create([Bind(Include="SourceCode")] CodeSnippet snippet)
        {
            if (ModelState.IsValid)
            {
                snippet.CreatedAt = DateTime.UtcNow;

                // We'll add the highlighting a bit later.

                _db.CodeSnippets.Add(snippet);
                _db.SaveChanges();

                return RedirectToAction("Details", new { id = snippet.Id });
            }

            return View(snippet);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
using System;
using System.Linq;
using System.Web.Mvc;
using Hangfire.Highlighter.Models;

namespace Hangfire.Highlighter.Controllers
{
    public class HomeController : Controller
    {
        private readonly HighlighterDbContext _db = new HighlighterDbContext();

        public ActionResult Index()
        {
            return View(_db.CodeSnippets.ToList());
        }

        public ActionResult Details(int id)
        {
            var snippet = _db.CodeSnippets.Find(id);
            return View(snippet);
        }

        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create([Bind(Include="SourceCode")] CodeSnippet snippet)
        {
            if (ModelState.IsValid)
            {
                snippet.CreatedAt = DateTime.UtcNow;

                // We'll add the highlighting a bit later.

                _db.CodeSnippets.Add(snippet);
                _db.SaveChanges();

                return RedirectToAction("Details", new { id = snippet.Id });
            }

            return View(snippet);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
Testing 123
using System;
using System.Linq;
using System.Web.Mvc;
using Hangfire.Highlighter.Models;

namespace Hangfire.Highlighter.Controllers
{
    public class HomeController : Controller
    {
        private readonly HighlighterDbContext _db = new HighlighterDbContext();

        public ActionResult Index()
        {
            return View(_db.CodeSnippets.ToList());
        }

        public ActionResult Details(int id)
        {
            var snippet = _db.CodeSnippets.Find(id);
            return View(snippet);
        }

        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create([Bind(Include="SourceCode")] CodeSnippet snippet)
        {
            if (ModelState.IsValid)
            {
                snippet.CreatedAt = DateTime.UtcNow;

                // We'll add the highlighting a bit later.

                _db.CodeSnippets.Add(snippet);
                _db.SaveChanges();

                return RedirectToAction("Details", new { id = snippet.Id });
            }

            return View(snippet);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
dafgsdfgsdfgsdfg
class A
{}
using System;
using System.Linq;
using System.Web.Mvc;
using Hangfire.Highlighter.Models;

namespace Hangfire.Highlighter.Controllers
{
    public class HomeController : Controller
    {
        private readonly HighlighterDbContext _db = new HighlighterDbContext();

        public ActionResult Index()
        {
            return View(_db.CodeSnippets.ToList());
        }

        public ActionResult Details(int id)
        {
            var snippet = _db.CodeSnippets.Find(id);
            return View(snippet);
        }

        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create([Bind(Include="SourceCode")] CodeSnippet snippet)
        {
            if (ModelState.IsValid)
            {
                snippet.CreatedAt = DateTime.UtcNow;

                // We'll add the highlighting a bit later.

                _db.CodeSnippets.Add(snippet);
                _db.SaveChanges();

                return RedirectToAction("Details", new { id = snippet.Id });
            }

            return View(snippet);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
            var result = new CalTwoDateResult()
            {
                StartDate = range.StartDate,
                EndDate = range.EndDate
            };

            DateTime startDate = result.StartDate.AddDays(1);
            DateTime endDate = result.EndDate.AddDays(1);
            int startYear = startDate.Year;
            int startMonth = startDate.Month;
            int startDay = startDate.Day;
            int endYear = endDate.Year;
            int endMonth = endDate.Month;
            int endDay = endDate.Day;

            if (endDay < startDay)
            {
                endMonth = endMonth - 1;
                if (endMonth == 0)
                {
                    endMonth = 12;
                    endYear = endYear - 1;
                }
                endDay = endDay + DateTime.DaysInMonth(endYear, endMonth);

            }
            result.NofDays = endDay - startDay;


            if (endMonth < startMonth)
            {
                endMonth = endMonth + 12;
                endYear = endYear - 1;
            }
            result.NofMonths = endMonth - startMonth;
            result.NofYears = endYear - startYear;


            if (result.NofDays > 0)
                result.LastCalendarDays = (int)(result.StartDate.AddMonths(result.NofYears * 12 + result.NofMonths + 1) - result.StartDate.AddMonths(result.NofYears * 12 + result.NofMonths)).TotalDays;
            else
                result.LastCalendarDays = 1;

            result.TotalYears = result.NofYears + (double)result.NofMonths / 12 + (double)result.NofDays / 365;
            result.TotalMonths = result.NofYears * 12 + result.NofMonths + (double)result.NofDays / result.LastCalendarDays;
using System;
using System.Linq;
using System.Web.Mvc;
using Hangfire.Highlighter.Models;

namespace Hangfire.Highlighter.Controllers
{
    public class HomeController : Controller
    {
        private readonly HighlighterDbContext _db = new HighlighterDbContext();

        public ActionResult Index()
        {
            return View(_db.CodeSnippets.ToList());
        }

        public ActionResult Details(int id)
        {
            var snippet = _db.CodeSnippets.Find(id);
            return View(snippet);
        }

        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create([Bind(Include="SourceCode")] CodeSnippet snippet)
        {
            if (ModelState.IsValid)
            {
                snippet.CreatedAt = DateTime.UtcNow;

                // We'll add the highlighting a bit later.

                _db.CodeSnippets.Add(snippet);
                _db.SaveChanges();

                return RedirectToAction("Details", new { id = snippet.Id });
            }

            return View(snippet);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
wdcvqwevqwdev
88
Console.WriteLine("許蓋功");
Console.WriteLine("許蓋功");
Console.WriteLine("alexandre machado");
Console.WriteLine("alexandre machado");
xdasd
using System;
using System.Linq;
using System.Web.Mvc;
using Hangfire.Highlighter.Models;

namespace Hangfire.Highlighter.Controllers
{
    public class HomeController : Controller
    {
        private readonly HighlighterDbContext _db = new HighlighterDbContext();

        public ActionResult Index()
        {
            return View(_db.CodeSnippets.ToList());
        }

        public ActionResult Details(int id)
        {
            var snippet = _db.CodeSnippets.Find(id);
            return View(snippet);
        }

        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create([Bind(Include="SourceCode")] CodeSnippet snippet)
        {
            if (ModelState.IsValid)
            {
                snippet.CreatedAt = DateTime.UtcNow;

                // We'll add the highlighting a bit later.

                _db.CodeSnippets.Add(snippet);
                _db.SaveChanges();

                return RedirectToAction("Details", new { id = snippet.Id });
            }

            return View(snippet);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
using System;
using System.Linq;
using System.Web.Mvc;
using Hangfire.Highlighter.Models;

namespace Hangfire.Highlighter.Controllers
{
    public class HomeController : Controller
    {
        private readonly HighlighterDbContext _db = new HighlighterDbContext();

        public ActionResult Index()
        {
            return View(_db.CodeSnippets.ToList());
        }

        public ActionResult Details(int id)
        {
            var snippet = _db.CodeSnippets.Find(id);
            return View(snippet);
        }

        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create([Bind(Include="SourceCode")] CodeSnippet snippet)
        {
            if (ModelState.IsValid)
            {
                snippet.CreatedAt = DateTime.UtcNow;

                // We'll add the highlighting a bit later.

                _db.CodeSnippets.Add(snippet);
                _db.SaveChanges();

                return RedirectToAction("Details", new { id = snippet.Id });
            }

            return View(snippet);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
the
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
test
qwe
public void none(int n){
  n += 1;
}
public void Test20908(){

}
public void Test20901(){

}
public class Foo2 {
    private string Bar { get; set; }
}
Deneme
xxxxxxxxxxxxxxx
new Exception("Foo")
var a =6;
public class Foo {
    private string Bar { get; set; }
}
Console.WriteLine("Hello");
public void 2080(){

}
public void Test2090(){

}
public void Test1090(){

}
werewrwer
Console.WriteLine("Salve, Juu!");
System.Console.WriteLine("Salve Ju!")
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
Console.WriteLine("asfkjaflkafj");
public class Demo {
}
;
var s = "SS";
using System.Net;
using System.Web.Mvc;
using Microsoft.SharePoint.Client;

namespace SharePointAddInWeb.Controllers
{
    public class HomeController : Controller
    {
        [SharePointContextFilter]
        public ActionResult Index()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            //using (var clientContext = spContext.CreateUserClientContextForSPHost())
            using (var clientContext = new ClientContext(spContext.SPHostUrl))
            {

                if (clientContext != null)
                {
                    var spUser = clientContext.Web.CurrentUser;
                    clientContext.Load(spUser, user => user.Title);
                    clientContext.ExecuteQuery();
                    ViewBag.UserName = spUser.Title;
                }
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
using System.Net;
using System.Web.Mvc;
using Microsoft.SharePoint.Client;

namespace SharePointAddInWeb.Controllers
{
    public class HomeController : Controller
    {
        [SharePointContextFilter]
        public ActionResult Index()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            //using (var clientContext = spContext.CreateUserClientContextForSPHost())
            using (var clientContext = new ClientContext(spContext.SPHostUrl))
            {

                if (clientContext != null)
                {
                    var spUser = clientContext.Web.CurrentUser;
                    clientContext.Load(spUser, user => user.Title);
                    clientContext.ExecuteQuery();
                    ViewBag.UserName = spUser.Title;
                }
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!")
    }
  }
}
using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World1111111!")
    }
  }
}
using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!")
    }
  }
}
using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!")
    }
  }
}
using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!");    
    }
  }
}
rtez
using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!");    
    }
  }
}
using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!");    
    }
  }
}
test
using System.Net;
using System.Web.Mvc;
using Microsoft.SharePoint.Client;

namespace SharePointAddInWeb.Controllers
{
    public class HomeController : Controller
    {
        [SharePointContextFilter]
        public ActionResult Index()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            //using (var clientContext = spContext.CreateUserClientContextForSPHost())
            using (var clientContext = new ClientContext(spContext.SPHostUrl))
            {

                if (clientContext != null)
                {
                    var spUser = clientContext.Web.CurrentUser;
                    clientContext.Load(spUser, user => user.Title);
                    clientContext.ExecuteQuery();
                    ViewBag.UserName = spUser.Title;
                }
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
using System.Net;
using System.Web.Mvc;
using Microsoft.SharePoint.Client;

namespace SharePointAddInWeb.Controllers
{
    public class HomeController : Controller
    {
        [SharePointContextFilter]
        public ActionResult Index()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            //using (var clientContext = spContext.CreateUserClientContextForSPHost())
            using (var clientContext = new ClientContext(spContext.SPHostUrl))
            {

                if (clientContext != null)
                {
                    var spUser = clientContext.Web.CurrentUser;
                    clientContext.Load(spUser, user => user.Title);
                    clientContext.ExecuteQuery();
                    ViewBag.UserName = spUser.Title;
                }
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
using System.Net;
using System.Web.Mvc;
using Microsoft.SharePoint.Client;

namespace SharePointAddInWeb.Controllers
{
    public class HomeController : Controller
    {
        [SharePointContextFilter]
        public ActionResult Index()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            //using (var clientContext = spContext.CreateUserClientContextForSPHost())
            using (var clientContext = new ClientContext(spContext.SPHostUrl))
            {

                if (clientContext != null)
                {
                    var spUser = clientContext.Web.CurrentUser;
                    clientContext.Load(spUser, user => user.Title);
                    clientContext.ExecuteQuery();
                    ViewBag.UserName = spUser.Title;
                }
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
using System.Net;
using System.Web.Mvc;
using Microsoft.SharePoint.Client;

namespace SharePointAddInWeb.Controllers
{
    public class HomeController : Controller
    {
        [SharePointContextFilter]
        public ActionResult Index()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            //using (var clientContext = spContext.CreateUserClientContextForSPHost())
            using (var clientContext = new ClientContext(spContext.SPHostUrl))
            {

                if (clientContext != null)
                {
                    var spUser = clientContext.Web.CurrentUser;
                    clientContext.Load(spUser, user => user.Title);
                    clientContext.ExecuteQuery();
                    ViewBag.UserName = spUser.Title;
                }
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
using System.Net;
using System.Web.Mvc;
using Microsoft.SharePoint.Client;

namespace SharePointAddInWeb.Controllers
{
    public class HomeController : Controller
    {
        [SharePointContextFilter]
        public ActionResult Index()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            //using (var clientContext = spContext.CreateUserClientContextForSPHost())
            using (var clientContext = new ClientContext(spContext.SPHostUrl))
            {
                clientContext.Credentials = new NetworkCredential("SPAdmin", "Adm+123", "CORP");

                if (clientContext != null)
                {
                    var spUser = clientContext.Web.CurrentUser;
                    clientContext.Load(spUser, user => user.Title);
                    clientContext.ExecuteQuery();
                    ViewBag.UserName = spUser.Title;
                }
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
public ActionResult Index()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            //using (var clientContext = spContext.CreateUserClientContextForSPHost())
            using (var clientContext = new ClientContext(spContext.SPHostUrl))
            {
                clientContext.Credentials = new NetworkCredential("SPAdmin", "Adm+123", "CORP");

                if (clientContext != null)
                {
                    var spUser = clientContext.Web.CurrentUser;
                    clientContext.Load(spUser, user => user.Title);
                    clientContext.ExecuteQuery();
                    ViewBag.UserName = spUser.Title;
                }
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
string s = "test";
use System;
public class HelloWorld{

int thisIsFine;
}
private static TResult RunSync<TResult>(Func<Task<TResult>> func)
    {
        return Task.Run<Task<TResult>>(func).Unwrap().GetAwaiter().GetResult();
    }
var x = 5;
hello var =x
while (true)
{
system.threading.sleep(1000);
}
var c = "123";
var x = 1;
Console.WriteLine("Hello, world!");