AspNetCore.Unobtrusive.Ajax
3.2.0
dotnet add package AspNetCore.Unobtrusive.Ajax --version 3.2.0
NuGet\Install-Package AspNetCore.Unobtrusive.Ajax -Version 3.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AspNetCore.Unobtrusive.Ajax" Version="3.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AspNetCore.Unobtrusive.Ajax" Version="3.2.0" />
<PackageReference Include="AspNetCore.Unobtrusive.Ajax" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AspNetCore.Unobtrusive.Ajax --version 3.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AspNetCore.Unobtrusive.Ajax, 3.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=AspNetCore.Unobtrusive.Ajax&version=3.2.0
#tool nuget:?package=AspNetCore.Unobtrusive.Ajax&version=3.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
@Html.RenderUnobtrusiveAjaxScript()
@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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.Extensions.FileProviders.Embedded (>= 6.0.36)
-
net7.0
- Microsoft.Extensions.FileProviders.Embedded (>= 7.0.20)
-
net8.0
- Microsoft.Extensions.FileProviders.Embedded (>= 8.0.15)
-
net9.0
- Microsoft.Extensions.FileProviders.Embedded (>= 9.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.