EnableCDN in toolkitscriptmanager not downloading minified files - c#

I have this ToolkitScriptManager in my Master page:
<asp:ToolkitScriptManager runat="server" EnableScriptGlobalization="false" ID="scrptManager"
LoadScriptsBeforeUI="false" ScriptMode="Release" EnableCdn="true">
</asp:ToolkitScriptManager>
Notice the ScriptMode="Release" and I have compilation debug="false" in my web.config
However, when the scripts get download to the client I get unminified javascripts. The ToolkitScriptManager downloads scripts from:
http://ajax.aspnetcdn.com/ajax/4.0/1/WebUIValidation.js
http://ajax.aspnetcdn.com/ajax/4.0/1/WebForms.js
How do I modify my ToolkitScriptManager to download minified version of these scripts?

This is just a theory. By check the following:
http://ajax.aspnetcdn.com/ajax/4.0/1/WebForms.js
vs
http://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js
I noticed the MicrosoftAjax.js file it is minified, however the WebForms.js file is not. I think your set up for the ToolkitScriptManager is correct and there are some issues with cdn conent. Again it's just a guess, to be sure, maybe you can ask on asp.net forums: http://forums.asp.net/
Hope this helps.

Related

Why bootstrap isn't loaded Quick Install Package

I'm building the ASP.Net Core Web Application
I installed bootstrap using Quick Install Package. So now I have it in my dependencies:
Also, there's a folder "node_modules" with bootstrap and everything is fine there, all classes are where they're supposed to be:
Then I created a view and in html wrote the following:
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css" />
When I hover the mouse over the href, I see a warning:
Path C:\Users\Shep\SportsStore\SportsStore\wwwroot\~node_modules not found
Well, it's true, because there's no such folder, but how to keep it from looking in wwwroot and use the specified folder? My wwwroot is empty, I guess it's because I didn't use bower
If I use the full path (href="C:/Users/Shep/SportsStore/SportsStore/node_modules/bootstrap/dist/css/bootstrap.css"), it seems right, but I bootstrap classes are unavailable:
<body>
<div class="panel-info">
</div>
</body>
and if I hover the mouse over, I see "Unknown CSS class 'panel-info'" even though there's this class in bootstrap.css
.panel-info {
border-color: #bce8f1;
}
I'm not using Angular and haven't created any js files of my own yet.
I have seen lots of similar issues and haven't found suitable solution, sorry if it's a duplicate
In ASP.NET Core, the runtime supports a piece of middleware called StaticFiles that allows anything in the /wwwroot folder to be accessible from the browser. But since the node_modules directory is outside of /wwwroot ,that problem occurs .
You can use Library Manager/Bundler and Minifier to copy the files into wwwroot . There are a lot of solutions you could find from here .

ASP.NET application not finding DLLs in bin folder

I am maintaining a website that is entirely written in ASP classic. I'm adding some new integrations using ASP.NET, but having some trouble.
My application runs 100% fine in Visual Studio, but when I publish it I'm getting this error:
Parser Error Message: Could not load type 'Int.OAuth'
Source Error:
Line 1: <%# Page Language="C#" AutoEventWireup="true" CodeBehind="OAuth.aspx.cs" Inherits="Int.OAuth" %>
That line comes from OAuth.aspx
Visual Studio puts the bin folder in the folder with the .aspx file correctly, and it contains all the .dlls, but it seems like ASP.NET can't find them. Could this be because my application is not at the site root? I have the app under: /ADMIN/api/services/int/.
Things I've tried:
1. Tried adding the bin folder to the assembly binding.
I saw many sources online saying that to tell ASP.NET about a folder with DLLs, you add this to your web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin/" />
</assemblyBinding>
</runtime>
I tried doing that, using a relative paths and also an absolute path, and double checked the paths, but that didn't have any effect.
2. Tried using CodeFile= instead of CodeBehind=
Sources online also suggested changing:
<%# Page Language="C#" AutoEventWireup="true"
CodeBehind="OAuth.aspx.cs" Inherits="RqQb.OAuth" %>
to
<%# Page Language="C#" AutoEventWireup="true"
CodeFile="OAuth.aspx.cs" Inherits="RqQb.OAuth" %>
This was inconvenient because Visual Studio does not upload the aspx.cs files when publishing, so I had to do that manually every time I made the change.
It still didn't solve the problem though. The using statements in OAuth.aspx.cs then began having errors. These were external libraries, and were all in the bin folder, but apparently not being found.
3. Tried changing the output path to /bin
Well this seemed like it wouldn't change anything, because it was working just fine in Visual Studio on localhost, but it would break when published (and all the DLLs were in the bin folder correctly) but I checked anyway and Build -> Output path was already correctly set to bin\.
4. Tried restarting visual studio, stopping localhost, cleaning, rebuilding then publishing again.
Didn't change anything.
For that one smart aleck who always asks: my problem is that I'm having an error, so my question is how do I get rid of this error?

Scripts.Render is not working

I'm developing ASP.NET MVC Razor project using monodevelop 5.9.6 and I added all packages necessary for bundling (System.Web.Optimization), in BundleConfig I'm adding
bundles.add(ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
and others. In Global.asax.cs I'm calling
BundleConfig.RegisterBundles(BundleTable.bundles);
However in _Layout.cshtml
#Scripts.Render("~/bundles/jquery")
is rendering as
<script src="/bundle/jquery?v=5GM9HLcujnDGm6SNVq0Es63_cXK2viQ4_nYEpm02Ls1"></script>
when running, causing "Failed to load resource (404)" javascript error, because all jquery's files are not rendered as it should be.
I need to render all jquery files and style files.
It's a feature of Bundling and Minification. All of jquery and css file grouped into one file when you enable Bundling and Minification and it works in two conditions
protected void Application_Start()
{
//Enabling Bundling and Minification
BundleTable.EnableOptimizations = true;
}
<compilation debug="false" targetFramework="4.0">
IF you want each file render separately use
compilation debug = "true" and
BundleTable.EnableOptimizations = false;.
But it's not a good practice when deploying code to production server.
Why 404 : If you can share your rendering code for jquery and css file I can try why 404 error is coming.enter code here
Thanks

Angular JS file download

I am trying to download file on a link click following this stackoverflow question Angularjs simple file download. After i click the link file downloads with error saying Failed No file. I have checked projects App_Data folder file is present there. Can anyone help figure out the issue.
<a target="_self" download="{{q.FileName}}" ng-href="{{q.QuizFile}}" href="#">Open File</a>
It renders into this path...
<a target="_self" download="Discussion.docx" ng-href="~/App_Data/74edf10b-5c18-472f-92bb-c64f55575b29/Discussion.docx" href="~/App_Data/74edf10b-5c18-472f-92bb-c64f55575b29/Discussion.docx">Open File</a>
The tilde in the path name doesn't mean anything in JavaScript. Its a convenience in mvc that resolves server side. Pass the path without the tilde.

View ascx.cs files from deployed website?

I've got a website that I published on IIS, but it seems like I've got the wrong version of source code in my dev environment.
I just need the code from 1 ascx.cs file.
Can I get to the contents of an ascx.cs file from a deployed website?
I've tried using .NET Reflector as suggested on other posts, but it seems like this tool only gives me access to my normal classes and not to the .ascx.cs files. Or am I just missing that?
EDIT:
Additional information as requested in answers.
<%# Control Language="C#" AutoEventWireup="true" CodeFile="timesheet.ascx.cs" Inherits="controls_timesheet" %>
You should use the DLL of the compiled web site to get the class that represents your .ascx.cs file.
For example, if your project is called MyWebSiteProject, you should have a MyWebSiteProject.dll on your /bin folder.
Open this DLL with .net Reflector, or http://ilspy.net/, if your control is named MyUserControl, it should be inside the namespace MyWebSiteProject.
Please double check your project's and controls namespace first.
Hope this helps, good luck :)

Categories