What does AspNet.ScriptManager.bootstrap do? - asp.net

I was trying to update bootstrap from 4.6.0 to 5.1.3, and when I do so I get the error message 'bootstrap 5.1.3' is not compatible with 'AspNet.ScriptManager.bootstrap 4.6.0 constraint: bootstrap (>= 4.5.9 && <= 4.6.1)'.
The latest version of AspNet.ScriptManager.bootstrap is 4.6.0 (released 2021-03-16).
What does AspNet.ScriptManager.bootstrap do and how can I replace it?

First a bit of background. The type PreApplicationStartCode is used to hookup bundles. The type is used by convention, it is static and has a static method Start (no parameters). It gets called by System.Web.Optimization.
So, AspNet.ScriptManager.bootstrap consists of a dll which contains a namespace which contains a type of PreApplicationStartCode which has a Start method which adds a ScriptResourceDefinition to the ScriptManager.ScriptResourceMapping.
It can be replaced by adding a call in your Application_Start handler (or a method it calls, typically BundlesConfig.RegisterBundles) to
ScriptManager.ScriptResourceMapping.AddDefinition("bootstrap",
new ScriptResourceDefinition {
Path = "~/Scripts/bootstrap.min.js",
DebugPath = "~/Scripts/bootstrap.js",
CdnPath = "https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js",
CdnSupportsSecureConnection = true,
LoadSuccessExpression="window.jQuery.fn.carousel"
});
And voila, the package AspNet.ScriptManager.bootstrap can be removed and there will be no problem updating bootstrap.

Related

Property 'downloadURL' not found on object of type 'FIRStorageMetadata *' - Getting this error when trying to build a Flutter project

I'm trying to build a Flutter project on Xcode with firebase installed. I'm getting the following error: Property 'downloadURL' not found on object of type 'FIRStorageMetadata *'
This is being caused by the following section in the FirebaseStoragePlugin.m file:
NSString *path = call.arguments[#"path"];
NSDictionary *metadataDictionary = call.arguments[#"metadata"];
FIRStorageMetadata *metadata;
if (![metadataDictionary isEqual:[NSNull null]]) {
metadata = [self buildMetadataFromDictionary:metadataDictionary];
}
FIRStorageReference *fileRef = [[FIRStorage storage].reference child:path];
[fileRef putData:data
metadata:metadata
completion:^(FIRStorageMetadata *metadata, NSError *error) {
if (error != nil) {
result(error.flutterError);
} else {
// Metadata contains file metadata such as size,
// content-type, and download URL.
NSURL *downloadURL = metadata.downloadURL; <---------------- This line
result(downloadURL.absoluteString);
}
}];
}
Since I didn't generate this code, I don't particularly want to edit it as it should really be working out of the box. I've tried to change the method to see whether later versions of Firebase might only accept another function but to no avail. What shall I do in this situation? Should I perhaps try to rebuild the project with a higher version of Firebase or is there a one line fix?
The downloadURL was removed from the StorageMetadata class in May 2018. If your native iOS code still uses that, it's high time to find an updated SDK or update your code to match the documentation on uploading a file and getting its download URL.
If you're using the FlutterFire binding libraries, upgrade to the latest version (as I definitely don't see any reference to metadata.downloadURL in its current code base). If you're using another library, check if the latest version of that solves the problem - or otherwise consider switching to the FlutterFire libraries as those are quite actively maintained.

BundleTransformer for less complaining "Could not find a factory, that creates an instance of the JavaScript engine"

If you upgrade from version 1 to version 2 of BundleTransformer you may get this message:
Could not find a factory, that creates an instance of the JavaScript
engine with name MsieJsEngine.
Like me, you may not even have realized you've upgraded more than just a point release.
How to fix?
Version 2 DOES NOT USE WEB.CONFIG for configuration anymore
So start by removing it and read the rest of this link
https://github.com/Taritsyn/JavaScriptEngineSwitcher/wiki/How-to-upgrade-applications-to-version-2.X
Basically you will be doing the following:
Removing existing web.config nodes for javscript engine
Adding to someplace like global.asax some initialization code
Install Nuget packages for the engines you want to use
Make sure to add a using statement to be able to use extension methods (if you choose that way)
I ended up with something like this:
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.Msie;
using JavaScriptEngineSwitcher.V8;
....
public class JsEngineSwitcherConfig
{
public static void Configure(JsEngineSwitcher engineSwitcher)
{
engineSwitcher.EngineFactories
.AddMsie(new MsieSettings
{
UseEcmaScript5Polyfill = true,
UseJson2Library = true
})
.AddV8();
engineSwitcher.DefaultEngineName = MsieJsEngine.EngineName;
}
}
I'm following the instructions, but my code is now breaking on BundleConfig
var cssTransformer = new StyleTransformer();
In the name attribute of /configuration/bundleTransformer/less/jsEngine configuration element not specified a name of JavaScript engine.
If you have not installed JavaScript engine, then for correct working
of this module is recommended to install one of the following NuGet
packages: * JavaScriptEngineSwitcher.Msie *
JavaScriptEngineSwitcher.V8 * JavaScriptEngineSwitcher.ChakraCore
After package is installed, need set a name of JavaScript engine (for
example, MsieJsEngine) to the name attribute of
/configuration/bundleTransformer/less/jsEngine configuration
element.

Meteor's Iron.Router adding an extra "/" to route names and not allowing home route

I am having a problem getting iron-router to correctly store and access routes. It appears that Iron.Router is adding an extra slash (/) before the route names, not ignoring case for template names, and not creating a default route.
I am adding Iron.Router to a simple testing app I have that I have split up for separate pages, but I cannot get any page to work as documented either with the map() or route() functions. I have spent hours trying options and searching and I seem to be the only one who ever had this problem. So I set up a minimum project to test. I created a new meteor project, removed the files, then copied basic.js and basic.html from https://github.com/EventedMind/iron-router/tree/devel/examples. All this example does is show three pages when you click between them. I then…
vagrant#precise32:/vagrant/test$ meteor add iron:router
vagrant#precise32:/vagrant/test$ meteor update
This project is already at Meteor 0.9.3.1, the latest release.
Your packages are at their latest compatible versions.
vagrant#precise32:/vagrant/test$ npm version
{ http_parser: '1.0',
node: '0.10.32',
v8: '3.14.5.9',
ares: '1.9.0-DEV',
uv: '0.10.28',
zlib: '1.2.3',
modules: '11',
openssl: '1.0.1i',
npm: '2.1.2' }
vagrant#precise32:/vagrant/test$ ls
basic.html basic.js.
vagrant#precise32:/vagrant/test$ meteor
It started successfully, but threw a JS error on in Chrome (or FF). Exception from Tracker recompute function: Error: Couldn't find a template named "/" or "". Are you sure you defined it? Well yes, I did. Giving the route a blank name generates no error and no home page. So next I tried adding “/one” on the URL. I then get the JS error Error: Oh no! No route found for path: "/one". Next I changed the parameter in my route() call from “/one” to “one” and got this error: Error: Couldn't find a template named “one” or “one”. Are you sure you defined it? I then tried adding explicit code for route “one”: “function() { this.render(“Home”)} to reference the template “Home” using the same case. I got the exact same error message as without the explicit code. The only way I could get page one to display was to changed the name from “One” to “one” in the HTML. I couldn't get the default page to display at all.
When poking around (using Chrome’s console) in some internal variables, I found Router.routes, which has this highly suspicious content:
>Router.routes.forEach( function(v) {console.info("name = '%s', originalPath = '%s', re = '%s'",v.name,v.originalPath,v.re)})
2014-10-04 16:10:07.756 name = '/', originalPath = '//', re = '/^//?$/i'
2014-10-04 16:10:07.757 name = '/one', originalPath = '//one', re = '/^//one/?$/i'
2014-10-04 16:10:07.758 name = '/two', originalPath = '//two', re = '/^//two/?$/i'
(If I name the path "one", then the route will show 'one' as the name, and '/one' as the originalPath.
Details: This is a brand new folder with only these two files in it (and the hidden .meteor folder). The only package added was “iron:router”. I did a meteor update just before my last round of testing (one hour ago). I have set no environment variables. I have the latest version of Chrome & FireFox. I am using VirtualBox via Vagrant from Window 8 with 12G memory. Every other Meteor project I’ve done so far works, (well except for some trying to use jQuery).
If this was a bug in Iron:router, someone else would have noticed, but there are no more settings I can find anywhere that could be adding or subtracting the extra “/” in Iron-Router. Anyone have any ideas of what I need to look for for making a vanilla Iron-Router work with a vanilla Meteor project on my machine?
You are really out of luck because your problem is very simple : you are running examples which are intended to work with the LATEST iron:router#1.0.0-pre3, but your iron:router version is most likely 0.9.4.
Try this :
meteor remove iron:router
meteor add iron:router#1.0.0-pre3
If you want a little more insight, routes used to be declared with name first and path as an option, this is now the contrary.
0.9.4
Router.map(function(){
this.route("home",{
path:"/"
});
});
1.0.0-pre3
Router.route("/",{
name:"home"
});

ASP.NET bundling and minification not producing query string params

I've been using ASP.NET bundling and minification with the nugget package Microsoft.AspNet.Web.Optimization.
I noticed yesterday that the majority of my bundle files no longer have the v query string parameter to the exception of one of them:
/Sgc.Web/bundles/css/JQueryUI
/Sgc.Web/bundles/css/DefaultPage
/Sgc.Web/bundles/js/Menu
/Sgc.Web/bundles/js/DefaultPage
/Sgc.Web/bundles/js/ReportOutputs
/Sgc.Web/bundles/js/UnderscoreBackbone?v=4YsZ6DBVserabs64GE87Ua4d51aeg0D1wXHWNe3E6NU1
The JS bundle that still has the query string always keeps on producing different v param values after I do changes on it (as expected). However the remaining bundles (either css or js) when I make changes on their css or js files they do incorporate those changes but do not produce a v param value any more.
The C# code to perform the bundling:
// -- create and add CSS bundles without minification
BundleTable.EnableOptimizations = true;
bundles.Add(new Bundle("~/bundles/css/JQueryUI").Include(
"~/Styles/Gui/jquery-ui-1.10.4-custom.css",
"~/Styles/Gui/jquery-ui-custom.css",
"~/Styles/Gui/jquery.ui.combogrid.css"));
bundles.Add(new Bundle("~/bundles/css/DefaultPage").Include(
"~/Styles/Default.css",
"~/Content/toastr.min.css"));
// -- create and add JS bundles without minification
bundles.Add(new Bundle("~/bundles/js/DefaultPage").Include(
"~/Scripts/Defaults.js",
"~/Scripts/toastr.min.js"));
bundles.Add(new Bundle("~/bundles/js/Menu").Include(
"~/Scripts/Gui/Menus/SuperFish/jquery.hoverIntent.r7.min.js",
"~/Scripts/Gui/Menus/SuperFish/superfish1_7_4.min.js",
"~/Scripts/Gui/Menus/SuperFish/factory.js"));
bundles.Add(new Bundle("~/bundles/js/UnderscoreBackbone").Include(
"~/Scripts/underscore.min.js",
"~/Scripts/backbone.min.js"));
bundles.Add(new Bundle("~/bundles/js/ReportOutputs").Include(
"~/Scripts/Gui/jquery-visibility.js",
"~/Scripts/UserControls/ReportOutputs.js"));
//-- if in Release mode, then minify all the bundles
if (!System.Web.HttpContext.Current.IsDebuggingEnabled)
{
CssMinify cssMinify = new CssMinify();
JsMinify jsMinify = new JsMinify();
foreach (Bundle bundle in bundles)
{
if (bundle.Path.Contains("/js"))
{
bundle.Transforms.Add(jsMinify);
}
else
{
bundle.Transforms.Add(cssMinify);
}
}
As can be seen from above I'm building the bundle with the Bundle super class instead of the StyleBundle or ScriptBundle sub classes. However I also tried to make bundles with these 2 subclasses and the result was the same: all bundles still didn't had v param to the exception of the UnderscoreBackbone bundle. As far as I know there is no difference in the way the UnderscoreBackbone bundle is being made and the remaining bundles.
I'm using,
Windows 8.1
VS Premium 2013 with Update 1
Microsoft.AspNet.Web.Optimization 1.1.3
WebGrease 1.6.0
Microsoft.Web.Infrastructure 1.0.0.0
Json.NET (Newtonsoft.Json) 6.0.1
ANTLRv3 3.5.0.2
Does anyone ever faced this kind of problem before or any hint as to where can I look for a solution to it ?
Thanks in advance,
MggLp
Sometimes, in views, we might be doing something like -
Scripts.Render("/bundles/js/Default‌​Page")
but the correct syntax to get hash -
Scripts.Render("~/bundles/js/Default‌​Page").
It might be the matter of absolute and relative path.
Using ~ we can get the querystring for the bundled files.

Can't set up asp.net mvc 2 RC and spark view engine

Does omebody has ideas how to fix "Method not found: 'Void System.Web.Mvc.ViewContext..ctor(System.Web.Mvc.ControllerContext, System.Web.Mvc.IView, System.Web.Mvc.ViewDataDictionary, System.Web.Mvc.TempDataDictionary)'." exception. This solution doesn't work http://dotnetslackers.com/articles/aspnet/installing-the-spark-view-engine-into-asp-net-mvc-2-preview-2.aspx.
Thans for all.
I had to download the spark view engine source code (http://sparkviewengine.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27600). Once I did that I went through each of the projects that had a reference to the 1.0 version of System.Web.Mvc assembly and updated to reference to point to System.Web.Mvc 2.0. From there you can build the solution (in visual studio) and you will find that a whole bunch of tests start to fail. You can attempt to fix them (by adding the additional TextWriter parameter you will find is now needed). You will also see that the SparkView.cs file complains about a missing parameter. In the Render method (line 100 of the source code I downloaded) I had to update the instantiation of the wrappedViewContext to look like this (add writer to the end of the list of parameters):
public void Render(ViewContext viewContext, TextWriter writer)
{
var wrappedHttpContext = new HttpContextWrapper(viewContext.HttpContext, this);
var wrappedViewContext = new ViewContext(
new ControllerContext(wrappedHttpContext, viewContext.RouteData, viewContext.Controller),
viewContext.View,
viewContext.ViewData,
viewContext.TempData,
writer); // <-- add the writer to the end of the list of parameters
...
}
Once the code is updated you can run the build.cmd script that is in the root of the source you downloaded. The build process will create a zip file in the build/dist folder. Take those new dll's and add them to your website. Things should work once again.
At the time of this answer, MVC 2 RC2 bits are available at sparkviewengine.codeplex.com
http://sparkviewengine.codeplex.com/releases/view/41143
It was actually Erik from the post mentioned by R0MANARMY who helped get those bits out there.
Looks like you can also download compiled binaries from here. As the post says, it isn't a final (or official) release, but at least it seems like the unit tests pass.

Resources