Home Controller
Gönderilme zamanı: 22 Ara 2020 02:11
TECXT
Kod: Tümünü seç
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AspNetCore.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
var resultType = true; // false ise NotFound Döndürür. True ise Index View'ini döndürür
if (resultType)
return View();
else
return NotFound();
}
Kod: Tümünü seç
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AspNetCore.Controllers
{
public class HomeController : Controller
{
public int Index()
{
return 5;
}
Kod: Tümünü seç
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AspNetCore.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Merhaba";
}
Kod: Tümünü seç
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AspNetCore.Controllers
{
public class HomeController : Controller
{
public ViewResult Index()
{
return View();
}
Kod: Tümünü seç
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AspNetCore.Controllers
{
public class HomeController : Controller
{
public StatusCodeResult Index()
{
return StatusCode(500);
}
Kod: Tümünü seç
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AspNetCore.Controllers
{
public class HomeController : Controller
{
public OkResult Index()
{
return Ok();
}
Kod: Tümünü seç
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AspNetCore.Controllers
{
public class HomeController : Controller
{
public NotFoundResult Index()
{
return NotFound();
}
Kod: Tümünü seç
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AspNetCore.Controllers
{
public class HomeController : Controller
{
public NoContentResult Index()
{
return NoContent();
}
Kod: Tümünü seç
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AspNetCore.Controllers
{
public class HomeController : Controller
{
public UnauthorizedResult Index()
{
return Unauthorized();
}
Kod: Tümünü seç
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
namespace aspNetCore.Controllers
{
public class HomeController : Controller
{
public BadRequestResult Index()
{
return BadRequest();
}
}
}
Kod: Tümünü seç
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
namespace aspNetCore.Controllers
{
public class HomeController : Controller
{
public JsonResult Index()
{
return Json(new { Name = "Ali", Surname = "Rüzgar" });
}
}
}
Kod: Tümünü seç
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
namespace aspNetCore.Controllers
{
public class HomeController : Controller
{
public FileResult Index()
{
var file = System.IO.File.ReadAllBytes(@"c:\Test\Test.txt");
return File(file,"text/plain");
}
}
}