I'm using Antaris RazorEngine inside a sharepoint webpart to display and render my data using razor, to completely separate the backend from the frontend styling and avoid the need to recompile my component.
I make the template key the same as the file name, Then check
If the web application is in debug mode, or the template isn't cached >>Then
I recompile the template
The problem happens, when I try to call "RunCompile" using the same key, which is the razor file name, I get an exception that there's a template already using the same Key.
What I need to do is to delete the cached template, recompile and cache it to reflect the changes made to the razor template code.
How to Delete a Cached template?
Or How to overwrite or recompile a cached template?
Related
I am using Symfony 2.8 and I want to render a template in a Symfony Console application. Basically I can render the template but it is trying to fetch assets from file protocol. I need those assets to be fetched from http protocol in order to creating a pdf from that template. I did try scopes but it did not work.
Actually the question is that I want the template to be rendered with correct asset and image urls. I want to get fully rendered html.
I'm writing a custom Drupal module for a mobile service. That module acts like a web form, but I'm having a problem when uploading a file. All values are inserted into the database successfully except for the file.
I think the function "_webform_client_form_submit_process" is not calling "_webform_submit_file". You can try following solution
1. Try using updating your webform module with the latest release.
2. Try removing your file upload field from fieldset, if its in any.
3. Check the temp and destination directory permission.
I've almost went over the code of the webform module and I solved it now, you have to use file_save and get the $file->fid and pass it to the data object of the submissions object, then call webform_submission_insert and get the $sid and pass it to file_usage_add, this got my module working
Background
I have an ASP.NET Web Forms app that I want to localize using .RESX files. I already know how to do this using .ASPX files. However, my application uses some .ASPX files... as well as some plain .HTML files.
(I am doing a lot of KnockoutJs, where the app retrieves the reusable HTML templates and injects them into the DOM as needed.)
I can't take the following approach in the HTML files, since the <%$ code would not be executed.
<%$ Resources:Main, WelcomeMessage %>
The Question
Is it possible to use C# code to process a plain HTML file against a RESX file to generate an HTML file that has been localized?
(I NEED A SOLUTION WITHOUT USING AN .ASPX FILE)
If this is possible, then I might be able to create a web service that will apply a RESX file to an HTML file and return the resulting HTML string.
Answer
I think the answer.... is No.
There does not seem to be an easy way to do this with ASP.NET Web Forms. So instead I switched my project to use ASP.NET MVC.... where this problem is more readily solved.
In case you are interested... here's what I did in MVC:
I changed the HTML files to .cshtml files (which support syntax that works with .RESX files). I created a controller I call HtmlController with a GetHtml action. The GetHtml method takes a URL as a parameter, and renders the contents of the requested .cshtml file, which is returned as a PartialView.
Now right after my page loads, I can fire Ajax requests to retrieve some shared HTML templates by calling that GetHtml action on HtmlController. The HTML content of my requested .cshtml file is localized against my .RESX file and then returned as the result of my Ajax call. I can then bind it on the page.
This works particularly well for shared HTML templates that I reuse across various pages, but I still need to have them localized for the currently selected Culture.
In retrospect
I still feel moving to MVC was the right decision.
However..... I suppose after having switched to MVC.... it might have been simpler to just directly render partial views (for each of those shared templates) on each page that needs access to them.
Then I could have avoided making separate Ajax calls to pull this stuff down when the page loads.
[FacePalm]
We have legacy code to maintain and, to solve a specific customer customization problem, we want to route calls to some files to other files. That is, when the app calls a particular ASPX, it will end up hitting another ASPX.
If you call:
www.foo.com/admin/admin.aspx
It will actually hit:
www.foo.com/customizations/customer1/admin/admin.aspx
This is not a good design but this is legacy code. We just want to solve this.
We are using the System.Web.Routing framework to solve it. This works fine when you set RouteExistingFiles to true, except for static files (CSS, JavaScript and Images).
When I first tried it, it retrieved this error:
There is no build provider register for the extension '.css'.
So I did register a build provider in the web.config file for the .css extension. I used this build provider: PageBuilderProvider because someone recommended it in the internet.
It works! But the CSS is being served with text\html content type.
How do I achieve this?
TL;DR: I want to use routes in ASP.NET Web Forms to make a call for a specific CSS file to actually retrieve another one. A customer needs this for customization.
Try coding a HttpHandler. I had to do something similar but for PDF files, I coded a custom HttpHandler in the end - works very well. You can even set the content type in the HttpHandler code and have a pattern matched path the handler will be used for in the web.config. You can also configure it in web.config not to execute if the path does not point to an existing file e.g. so a 404 is returned without having to code that in the handler itself. I can't post my code (VB.NET) ATM because I'm using a tablet but google search for tutorials. You will also probably need to use the TransmitFile function to actually write out the css file. Is it a web forms project or web site? If its a web site there is a special way of registering the HttpHandler in the web.config.
I am using ASP.NET optimization package to minify and bundle the scripts, and CSS files.
I am also developing a mobile UI for my ASP.NET application which uses a HTML5 cache manifest.
The optimization package updates the version of the dynamic bundle URL when the files change and the application cache is recycled.
I would like to be able to update my manifest version whenever this happens and include the dynamic URLs the optimization package provides in the manifest.
How can I read the current version (the "v" parameter) or anything else to trigger a manifest update?
/_assets/bundles/global?v=fmbQlO0mGjXyliVEBImQIr5yoMX0Tw0tlMK45jlwHZ81
Example Code:
string version= "2.6";
StringBuilder output = new StringBuilder();
output.AppendLine("CACHE MANIFEST");
output.AppendLine(string.Format("# v{0}", ??????));
output.AppendLine("CACHE:");
output.AppendLine(Scripts.Url("~/bundles/global").ToString());
...
The Application Manifest will automatically trigger an update if it is changed.
With static assets, people usually changed a version number in a comment so that the file was changed and would trigger an update, even though the content under the CACHE, NETWORK and FALLBACK sections were unchanged.
When you are using the URLs generated by System.Web.Optimization, the URL will change when the content of any of the CSS or JavaScript files in the bundles changes. This means that the manifest file will automatically be different to the previous version of the file and will trigger an update.
There is no need to force the file to be different by updating a version comment.