Guler.Editor.AspNet.Mvc5
0.2.0-alpha.0
dotnet add package Guler.Editor.AspNet.Mvc5 --version 0.2.0-alpha.0
NuGet\Install-Package Guler.Editor.AspNet.Mvc5 -Version 0.2.0-alpha.0
<PackageReference Include="Guler.Editor.AspNet.Mvc5" Version="0.2.0-alpha.0" />
<PackageVersion Include="Guler.Editor.AspNet.Mvc5" Version="0.2.0-alpha.0" />
<PackageReference Include="Guler.Editor.AspNet.Mvc5" />
paket add Guler.Editor.AspNet.Mvc5 --version 0.2.0-alpha.0
#r "nuget: Guler.Editor.AspNet.Mvc5, 0.2.0-alpha.0"
#:package Guler.Editor.AspNet.Mvc5@0.2.0-alpha.0
#addin nuget:?package=Guler.Editor.AspNet.Mvc5&version=0.2.0-alpha.0&prerelease
#tool nuget:?package=Guler.Editor.AspNet.Mvc5&version=0.2.0-alpha.0&prerelease
Stylus.AspNet.Mvc5
ASP.NET MVC 5 (.NET Framework 4.8) için Stylus editör + dosya yöneticisi paketi.
Stylus.Core üstüne inşa edilmiştir. Web API 2 ApiController, HtmlHelper extension, IHttpHandler tabanlı embedded asset servisi, HttpContext.Current.User tabanlı authorization.
Hedef kullanıcı
Modern Stylus.AspNetCore (.NET 8+) yerine bu paket eski .NET Framework 4.8 / MVC 5 kod tabanları içindir — Emirhan'ın gözlemine göre Türkiye pazarındaki kurumsal CMS / admin panel projelerinin önemli bir kısmı hala bu sürümde.
Hızlı başlangıç
dotnet add package Stylus.AspNet.Mvc5
1. Application_Start (Global.asax.cs)
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using Stylus.AspNet.Mvc5.Bootstrap;
public class MvcApplication : HttpApplication
{
protected void Application_Start()
{
StylusMvc5Configuration.Configure(opts =>
{
opts.RootDirectory = Server.MapPath("~/App_Data/stylus-uploads");
opts.AllowedExtensions = new[] { ".jpg", ".png", ".pdf" };
});
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
2. App_Start/RouteConfig.cs
using Stylus.AspNet.Mvc5.Assets;
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapStylusAssets(); // /_stylus/assets/{stylus.js|stylus.css}
routes.MapRoute("Default", "{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
}
3. App_Start/WebApiConfig.cs
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes(); // Stylus file manager ApiController bunu kullanır
}
}
4. Razor view (Views/Home/Index.cshtml)
@model MyArticleViewModel
@using Stylus.AspNet.Mvc5.HtmlHelpers
@using (Html.BeginForm("Save", "Home", FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.StylusEditor(
id: "editor",
name: "Article",
value: Model.Article.Html,
options: new StylusEditorOptions
{
EnableFileManager = true,
ThumbnailWidth = 1024,
})
<button type="submit">Kaydet</button>
}
5. Controller (Controllers/HomeController.cs)
using Stylus.Core.Sanitization;
public class HomeController : Controller
{
private static readonly IStylusSanitizer Sanitizer = new DefaultStylusSanitizer();
[HttpPost, ValidateInput(false)]
public ActionResult Save(MyArticleViewModel model)
{
model.Article.Html = Sanitizer.Sanitize(model.Article.Html); // XSS savunma
// ... DB'ye yaz
return RedirectToAction(nameof(Index));
}
}
HtmlHelper options
Html.StylusEditor() extension parametresi StylusEditorOptions:
| Property | Default | Açıklama |
|---|---|---|
ShowToolbar |
true |
Toolbar gösterilsin mi |
ShowCharCount |
true |
Footer char counter |
EnableSourceView |
true |
</> toggle butonu |
EnableFileManager |
true |
Image butonu file picker dialog'unu açar |
FileManagerBaseUrl |
"/_stylus/files" |
Web API 2 endpoint prefix |
AssetBaseUrl |
"/_stylus/assets" |
StylusAssetsHttpHandler URL'i |
ThumbnailWidth |
0 |
>0 ise img src /thumb URL'si |
ThumbnailFormat |
"jpeg" |
jpeg/png/webp |
Authorization + tenant isolation
Default DefaultMvc5StylusAuthorizationContext HttpContext.Current.User'dan ClaimsPrincipal okur (FormsAuthentication fallback olarak Identity.Name). Tenant scope: u-{userId} prefix.
StylusMvc5Configuration.Configure(
opts => opts.RootDirectory = ...,
auth =>
{
auth.RequireAuthentication = true;
auth.TenantClaimType = "tenant_id";
auth.TenantPrefix = "tenant-";
});
Custom impl register etmek için:
StylusMvc5Configuration.UseAuthorization(new MyCustomAuthContext());
StylusMvc5Configuration.Configure(...); // En son
Asset pipeline
editor-core JS + CSS DLL'in içinde EmbeddedResource olarak gömülüdür. routes.MapStylusAssets() /\_stylus/assets/stylus.js ve /\_stylus/assets/stylus.css URL'lerini StylusAssetsHttpHandler'a bağlar — tüketici wwwroot/Scripts'e elle dosya kopyalama derdi yok.
Sınırlamalar (alpha)
- Anti-forgery Stylus endpoint'lerinde aktif değil — pilot/production'da custom
[ValidateAntiForgeryToken]filter eklenmeli (Faz 3 cila) - Asset cache busting yok — browser cache 1 saat, deployment sonrası kullanıcı F5 gerekebilir
- Linux runtime desteği yok — IIS Windows-only (zaten ASP.NET 4.8 sınırı)
SDK-style csproj uyarısı
.NET Framework 4.8 SDK-style csproj transitif NuGet paket binding redirect'lerini Web.config'e otomatik üretmez. Tüketici Web.config'e manuel <runtime><assemblyBinding> section'ı eklemek zorunda. Sample AspNetMvc5Sample/Web.config içinde 16 yaygın paket için referans örnek var.
Bağımlılıklar
Stylus.Core(≥ 0.1.0-alpha.0)Microsoft.AspNet.Mvc(≥ 5.3.0)Microsoft.AspNet.WebApi.Core(≥ 5.3.0)Microsoft.AspNet.WebApi.WebHost(≥ 5.3.0)Microsoft.NETFramework.ReferenceAssemblies.net48(CI/Linux build için)
Lisans
MIT — Stylus open core taahhüdü.
Faz 2 alpha durumu
Bu paket Faz 2 alpha sürümündedir. Sub-faz 2E (.NET 4.8 desteği) içinde mimari ADR-002 ile 3-paket separation pattern'i benimsendi. Pilot dogfooding doğrulaması bekleniyor.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Guler.Editor.Core (>= 0.2.0-alpha.0)
- Guler.Editor.Licensing (>= 0.2.0-alpha.0)
- Microsoft.AspNet.Mvc (>= 5.3.0)
- Microsoft.AspNet.WebApi.Core (>= 5.3.0)
- Microsoft.AspNet.WebApi.WebHost (>= 5.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.0-alpha.0 | 78 | 5/1/2026 |