https://github.com/mjebrahimi/aspnetcore.unobtrusive.ajax
💻 Unobtrusive Ajax Helpers (like MVC5 Ajax.BeignForm and Ajax.ActionLink) for ASP.NET Core
https://github.com/mjebrahimi/aspnetcore.unobtrusive.ajax
ajax ajax-form ajax-helper ajax-upload asp-net-core asp-net-core-mvc aspnet-core aspnet-core-mvc aspnetcore aspnetcore-mvc aspnetcoremvc html-helper htmlhelper htmlhelpers jquery jquery-ajax unobstrusive
Last synced: 27 days ago
JSON representation
💻 Unobtrusive Ajax Helpers (like MVC5 Ajax.BeignForm and Ajax.ActionLink) for ASP.NET Core
- Host: GitHub
- URL: https://github.com/mjebrahimi/aspnetcore.unobtrusive.ajax
- Owner: mjebrahimi
- License: mit
- Created: 2020-11-01T04:04:30.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-17T12:38:16.000Z (9 months ago)
- Last Synced: 2025-04-02T05:07:19.719Z (about 1 month ago)
- Topics: ajax, ajax-form, ajax-helper, ajax-upload, asp-net-core, asp-net-core-mvc, aspnet-core, aspnet-core-mvc, aspnetcore, aspnetcore-mvc, aspnetcoremvc, html-helper, htmlhelper, htmlhelpers, jquery, jquery-ajax, unobstrusive
- Language: C#
- Homepage:
- Size: 771 KB
- Stars: 68
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/AspNetCore.Unobtrusive.Ajax)
[](https://www.nuget.org/packages/AspNetCore.Unobtrusive.Ajax)
[](https://opensource.org/licenses/MIT)
[](https://github.com/mjebrahimi/AspNetCore.Unobtrusive.Ajax)# 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
```ini
PM> Install-Package AspNetCore.Unobtrusive.Ajax
```### 2. Add Service and Middleware
```csharp
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
```html
@Html.RenderUnobtrusiveAjaxScript()
@RenderSection("Scripts", required: false)