AspNetCore.Unobtrusive.Ajax
💻 Unobtrusive Ajax Helpers (like MVC5 Ajax.BeignForm and Ajax.ActionLink) for ASP.NET Core
Install / Use
/learn @mjebrahimi/AspNetCore.Unobtrusive.AjaxREADME
AspNetCore.Unobtrusive.Ajax
Unobtrusive Ajax Helpers (like MVC5 Ajax.BeignForm and Ajax.ActionLink) for ASP.NET Core.
Features
- Works with Upload file.
- Works with
[AntiForgeryTokenValidation]. - Has
[AjaxOnly]attribute to limit Ajax-only Actions. - Has
httpRequest.IsAjaxRequest()extension method to check if the request is Ajax and decides to return PartialView or JSON result. - Additional overloads for Ease of Use.
- Adds necessary JS script automatically when you use the Ajax Helpers and removes JS script when you no longer use it (Optional - is by default).
- Can use CDN URL (for jQuery files) instead of Embedded script (Optional - not by default).
Method Usages
| Method | MVC 5
| ------------------------- | --------------------------------
| Html.AjaxBeginForm | instead of Ajax.BeginForm
| Html.AjaxBeginRouteForm | instead of Ajax.BeginRouteForm
| Html.AjaxActionLink | instead of Ajax.ActionLink
| Html.AjaxRouteLink | instead of Ajax.RouteLink
Get Started
1. Install package
PM> Install-Package AspNetCore.Unobtrusive.Ajax
2. Add Service and Middleware
public void ConfigureServices(IServiceCollection services)
{
//...
services.AddUnobtrusiveAjax();
//services.AddUnobtrusiveAjax(useCdn: true, injectScriptIfNeeded: false);
//...
}
public void Configure(IApplicationBuilder app)
{
//...
app.UseStaticFiles();
//It is required for serving 'jquery-unobtrusive-ajax.min.js' embedded script file.
app.UseUnobtrusiveAjax(); //It is suggested to place it after UseStaticFiles()
//...
}
3. Add Script Tag in Layout.cshtml
<!--Place it at the end of the body and after jQuery -->
@Html.RenderUnobtrusiveAjaxScript()
<!-- Or you can reference your local script file -->
@RenderSection("Scripts", required: false)
</body>
</html>
4. Use it
@using (Html.AjaxBeginForm(new AjaxOptions
{
HttpMethod = "post",
//Other options ...
}))
{
}
Demo
Checkout AspNetCore.Unobtrusive.Ajax.Demo for more samples.

Contributing
Create an issue if you find a BUG or have a Suggestion or Question.
If you want to develop this project :
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request
Give a Star! ⭐️
If you find this repository useful, please give it a star. Thanks!
License
Copyright © 2020 Mohammd Javad Ebrahimi under the MIT License.
Related Skills
node-connect
333.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
333.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.0kCommit, push, and open a PR
