After applying Webmatrix Refreshand uploading my site to Webhost, it now fails with this error
Compiler Error Message: CS0103: The name 'Assets' does not exist in the current context Source Error:
Line 9:
Line 10: // Add Validation scripts
Line 11: Assets.AddScript("~/Scripts/jquery.validate.min.js"); Line 12: Assets.AddScript("~/Scripts/jquery.validate.unobtrusive.min.js");
Everything works fine on my dev box and I have copied all the assemblies to the bin folder in the webhost . I believe they are missing some WebMatrix Refresh dll, BUT I don't know which one.
If I comment out the Assets.AddScripts, the page runs fine, BUT all validations then will not work.
So where can I find the ASSETS (I assume it's a dll)
Here check this out http://aspnetwebstack.codeplex.com/discussions/358176
Thanks
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
I fixed this problem by DownLoading WebMatrix RC candidate.
Then I created a Site using the Starter Template.
Then I copied all the dll from the Bin folder to my Site.
Then I opened my _LayoutPages and changed
@Assets.GetScripts()
TO @RenderSection("Scripts",required:false)
Then I opened all my .cshtml pages that referenced scripts and changed all
Assets.AddScript("~/Scripts/jquery.validate.min.js");
TO
will put a load script at that point. It is normal html and does nothing special. What Assests.Addscript was doing was to make a collection and then all the scripts were load at the point where Assets.GetScripts was called.
e.g in logins and register Assets.GetScript gets called and they will load in the middle of the page. No control on their order. Scripts should all be either in the header or at the end of <body> tag and in a particular order.
Agreed: so we should keep this open.
In fact it is also pretty annoying to edit all the pages that contain assets.Addscripts.
I have spent several hours trying to resolve without sucess.
Want to add that i was running Webmatrix 2 Beta and just did the upgrade to RC on Windows7 on my dev machine where it does not work anymore.
What type of solution are you looking for? I believe the Assets class was either moved in the RC or changed completely.
Do you have @Renderscripts declared at the bottom of your _layoutpages and
<scriptsrc="~/Scripts/jquery.validate.min.js"></script> at the very top of any page that needs to refrence it? If placeed at
the very top of the page it fires before any controls on the page loads.
All the validate.min is doing is simply to validate entries. If you create a site using the RC and compare with the older version, you will notice the changes made.
Anyway, it worked for me and you can see it here cbian.com, a live production site.
cheers,
yousaid
I have a post, earlier this month on the IIS forums about trying to get assets to work on my local IIS server. I had installed the web site on an IIS instance on my dev computer and it worked fine. When I tried to install the same website on a different
windows 7 computer it would show the Assetts error. I didn't get any response and had to reinstall the OS to get it to start working.
Downloading and installing webmatrix to enable IIS to work with the compiled website is not a solution.
The functionality for bundling and minification has been removed from the core ASP.NET Web Pages 2 assemblies. As a consequence, the Assets helper listed later in this document is not available. Instead, you must install the ASP.NET Optimization NuGet package.
For more information, see Bundling and Minifying Assets in an ASP.NET Web Pages (Razor) Site.
Note The RC release of ASP.NET Web Pages 2 does not support bundling and minification because the package that contains the required elements is not yet available in Microsoft WebMatrix. We apologize for this inconvenience. The package is expected to be
available in the final release of ASP.NET Web Pages 2 and WebMatrix 2.
...
Now use the following which is what the new Starter Site template is using
@* Remove this section if you are using bundling *@
@section Scripts {
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
}
I am not sure how bundling works or if it would be reliable. The people that created the Starter File template opted not to use it so after this fiasco of code breaking from Beta to RC, I think best to stay clear of Bundling which still appears to be in
Beta.
yousaid
Participant
811 Points
334 Posts
The name 'Assets' does not exist in the current context
Jun 08, 2012 02:18 AM|LINK
After applying Webmatrix Refreshand uploading my site to Webhost, it now fails with this error
Compiler Error Message: CS0103: The name 'Assets' does not exist in the current context
Source Error:
Line 9: Line 10: // Add Validation scripts Line 11: Assets.AddScript("~/Scripts/jquery.validate.min.js"); Line 12: Assets.AddScript("~/Scripts/jquery.validate.unobtrusive.min.js");Everything works fine on my dev box and I have copied all the assemblies to the bin folder in the webhost . I believe they are missing some WebMatrix Refresh dll, BUT I don't know which one.
If I comment out the Assets.AddScripts, the page runs fine, BUT all validations then will not work.
So where can I find the ASSETS (I assume it's a dll)
Abhishek Luv
Participant
1798 Points
479 Posts
Re: The name 'Assets' does not exist in the current context
Jun 08, 2012 02:54 AM|LINK
Here check this out http://aspnetwebstack.codeplex.com/discussions/358176
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
yousaid
Participant
811 Points
334 Posts
Re: The name 'Assets' does not exist in the current context
Jun 09, 2012 01:11 AM|LINK
I fixed this problem by DownLoading WebMatrix RC candidate.
Then I created a Site using the Starter Template.
Then I copied all the dll from the Bin folder to my Site.
Then I opened my _LayoutPages and changed
@Assets.GetScripts() TO
@RenderSection("Scripts", required: false)
Then I opened all my .cshtml pages that referenced scripts and changed all
Assets.AddScript("~/Scripts/jquery.validate.min.js"); TO
<script src="~/Scripts/jquery.validate.min.js"></script>
Hope this helps anyone else having same problem.
Cheers,
yousaid
amurad
Member
4 Points
7 Posts
Re: The name 'Assets' does not exist in the current context
Jun 09, 2012 03:53 AM|LINK
This is not a real solution.
will put a load script at that point. It is normal html and does nothing special. What Assests.Addscript was doing was to make a collection and then all the scripts were load at the point where Assets.GetScripts was called.
e.g in logins and register Assets.GetScript gets called and they will load in the middle of the page. No control on their order. Scripts should all be either in the header or at the end of <body> tag and in a particular order.
jmdh
Member
4 Points
3 Posts
Re: The name 'Assets' does not exist in the current context
Jun 09, 2012 07:04 AM|LINK
Agreed: so we should keep this open.
In fact it is also pretty annoying to edit all the pages that contain assets.Addscripts.
I have spent several hours trying to resolve without sucess.
Want to add that i was running Webmatrix 2 Beta and just did the upgrade to RC on Windows7 on my dev machine where it does not work anymore.
yousaid
Participant
811 Points
334 Posts
Re: The name 'Assets' does not exist in the current context
Jun 09, 2012 11:52 AM|LINK
What type of solution are you looking for? I believe the Assets class was either moved in the RC or changed completely.
Do you have @Renderscripts declared at the bottom of your _layoutpages and <script src="~/Scripts/jquery.validate.min.js"></script> at the very top of any page that needs to refrence it? If placeed at the very top of the page it fires before any controls on the page loads.
All the validate.min is doing is simply to validate entries. If you create a site using the RC and compare with the older version, you will notice the changes made.
Anyway, it worked for me and you can see it here cbian.com, a live production site.
cheers,
yousaid
craig_inb
Member
76 Points
31 Posts
Re: The name 'Assets' does not exist in the current context
Jun 13, 2012 02:32 PM|LINK
I have a post, earlier this month on the IIS forums about trying to get assets to work on my local IIS server. I had installed the web site on an IIS instance on my dev computer and it worked fine. When I tried to install the same website on a different windows 7 computer it would show the Assetts error. I didn't get any response and had to reinstall the OS to get it to start working.
Downloading and installing webmatrix to enable IIS to work with the compiled website is not a solution.
And neither is reinstalling the OS.
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: The name 'Assets' does not exist in the current context
Jun 13, 2012 05:48 PM|LINK
You need http://nuget.org/packages/Microsoft.AspNet.Web.Optimization
The package contains a Scripts class, and a Styles class. They both have a Render method which takes a comma separated list of strings:
@Scripts.Render("~/scripts/jquery-1.7.2.min.js", "~/scripts/knockout-2.1.0.js") @Styles.Render("~/Content/site.css")The Assets class has not been retained.
Web Pages CMS | My Site | Twitter
jusaha61
Member
8 Points
4 Posts
Re: The name 'Assets' does not exist in the current context
Jun 19, 2012 01:54 AM|LINK
hello
So how do I change these lines then:
They are in maps example after this line :thankscusman-tv
Member
9 Points
11 Posts
Re: The name 'Assets' does not exist in the current context
Jul 05, 2012 06:04 PM|LINK
Read the following:
http://www.asp.net/web-pages/overview/whats-new/top-features-in-web-pages-2
Changes for the RC Version (June 2012)
The functionality for bundling and minification has been removed from the core ASP.NET Web Pages 2 assemblies. As a consequence, the Assets helper listed later in this document is not available. Instead, you must install the ASP.NET Optimization NuGet package. For more information, see Bundling and Minifying Assets in an ASP.NET Web Pages (Razor) Site.
http://www.asp.net/web-pages/tutorials/performance-and-traffic/bundling-and-minifying-assets-in-an-aspnet-web-pages-(razor)-site
Note The RC release of ASP.NET Web Pages 2 does not support bundling and minification because the package that contains the required elements is not yet available in Microsoft WebMatrix. We apologize for this inconvenience. The package is expected to be available in the final release of ASP.NET Web Pages 2 and WebMatrix 2.
...
Now use the following which is what the new Starter Site template is using
_Layout File
Near the end, use something like
Code File(s)
Near the top, use something like
@* Remove this section if you are using bundling *@ @section Scripts { <script src="~/Scripts/jquery.validate.min.js"></script> <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script> }I am not sure how bundling works or if it would be reliable. The people that created the Starter File template opted not to use it so after this fiasco of code breaking from Beta to RC, I think best to stay clear of Bundling which still appears to be in Beta.