ASP.NET DocumentEditor: Set Static Files Path
source link: https://www.textcontrol.com/blog/2021/12/28/aspnet-document-editor-set-static-files-path/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
ASP.NET DocumentEditor
In recent versions, the static files path had to be defined for all routes in where the editor is used. In version 30.0, a new property has been introduced to define the static files path once for all routes. Previously, each path, where the editor was used, had to be defined individually in the Startup.cs like this:
// serve static linked files (JavaScript and CSS for the editor) app.UseStaticFiles(new StaticFileOptions { FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider( System.IO.Path.Combine(System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetEntryAssembly().Location), "TXTextControl.Web")), RequestPath = "/envelope/create/TXTextControl.Web" });
app.UseStaticFiles(new StaticFileOptions { FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider( System.IO.Path.Combine(System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetEntryAssembly().Location), "TXTextControl.Web")), RequestPath = "/collaboration/edit/TXTextControl.Web" });
In the above sample, the static files can be found from the following routes:
- .../envelope/create/
- .../collaboration/edit/
In version 30.0, by default, the static files are expected in the TXTextControl.Web folder location in the root of your web application.
For the above sample, only the following code is required in the Startup.cs:
app.UseStaticFiles(new StaticFileOptions { FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider( System.IO.Path.Combine(System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetEntryAssembly().Location), "TXTextControl.Web")), RequestPath = "/TXTextControl.Web" });
If the editor is used in any path in the application in a view, the static files are now found automatically:
@Html.TXTextControl().TextControl(settings => { settings.Dock = TXTextControl.Web.DockStyle.Fill; }).Render()
The virtual folder location and name of the static files can be changed in the Startup.cs (TXTextControl.Web.MyName in this case):
app.UseStaticFiles(new StaticFileOptions { FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider( System.IO.Path.Combine(System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetEntryAssembly().Location), "TXTextControl.Web")), RequestPath = "/TXTextControl.Web.MyName" });
Then, this path can be defined in the view using the StaticFilesPath property:
@Html.TXTextControl().TextControl(settings => { settings.Dock = TXTextControl.Web.DockStyle.Fill; settings.StaticFilesPath = "/TXTextControl.Web.MyName"; }).Render()
Learn more about the other new features, improvements and changes of TX Text Control 30.0:
ASP.NET
The first true WYSIWYG, HTML5-based Web editor and reporting template designer. Give your users an MS Word compatible editor to create powerful reporting templates anywhere - in any browser on any device. Our ASP.NET components combine the power of a reporting tool and an easy-to-use WYSIWYG word processor - fully programmable and embeddable in your ASP.NET application.
Related Posts
2021 Wrap Up - Rethinking Documents
by Bjoern Meyer| December 22, 20212021 was an exciting year for Text Control with new innovative products, features and technologies. This blog entry gives a quick overview of the last year and an outlook of what to expect in 2022.
DS Server 2.0 Released: Comments and Mobile View
by Bjoern Meyer| December 20, 2021We are very happy to announce the immediate availability of DS Server 2.0. Version 2.0 is based on the latest TX Text Control release 30.0 and gives access to the new features including MS Word compatible comments and a mobile view of the document viewer.
Using TX Text Control .NET Server for ASP.NET with .NET 6
by Bjoern Meyer| December 8, 2021This article shows how to use the TX Text Control ASP.NET document editor and the ServerTextControl class within a .NET 6 application in Visual Studio 2022.
NDC Oslo 2021 Impressions
by Bjoern Meyer| December 3, 2021This week, we exhibited at NDC Oslo - the largest in-person conference this year in Europe. We had a fantastic conference and gave hundreds of demos of our latest version 30.0.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK