Outputting .Css file asp.net - css

I am working on a asp.net webforms project. I wanted to know if it is possible to output a minified CSS file to my specific .aspx page. is it possible to do it with a stream writer class? Apologies if the question is not the clearest I have experience with mvc .net core, asp web forms not so much.

Related

How to use razor code in ASP.NET?

I don't know how to use the razor code in my asp.net project. I am reading this tutorial w3school , but when i write the code in my "defaul.aspx" file then it can't run. can any one please tell me that how exactly to use the razor code in ASP.NET
When you want to work with Razor in your asp.net Project, then you should create ".cshtml" file like Page.cshtml, write down all the code of Razor there. WebMatrix is a tool through which you can also create professional website of asp.net, and where you would have to handle the Razor. for further detail please see this liknk Razor in Asp.net

MVC 3.0 Razor Assembly Directive

What is the syntax/analogue for Assembly Directive http://msdn.microsoft.com/en-us/library/a7c375wt(VS.71).aspx in MVC 3.0 Razor
On MVC View i have this:
<%# Assembly Name="Web.Plugins.Authentication" %>
How i may say the same in MVC 3.0 razor view ?
More details and solution:
I did build pluggable MVC application where i am having one Main App and a lot of Plugins in it. All assemblies and views output from Plugins Apps located not in Bin directory of Main App, and in Razor case i was experienced some problems that views cant find model classes.
Finally i did come the solution for that problem. I did make output of all *.dll of Plugins Apps in to Bin Directory of "Main App".
You will not find the equivalent of the Assembly Directive in Razor.
The reason is somewhat convoluted, but it begins with the decision of the MVC team to use WebForms for the first two versions of ASP.NET MVC. WebForms are used for many more things than just views in MVC. What MVC does is simply to re-purpose the WebForms engine to render views.
On the other hand, Razor is a plain view engine. Its objective is to provide a language to describe the rendering of HTML in an MVC website, nothing more.
Perhaps if you detail what you want to achieve we could help you in more detail
Yet another.
web.config
system.web
compilation
assemblies
add assembly
MVC RazorView class(inherit BuildManagerCompliledView) is using BuildManagerWrapper.
If code base change ,implement IBuildManager.GetReferencedAssemblies method and custom WebPage Helper.
In that case all *.dll's should be located in the correct place - in Bin directory of the main project "Main App".

Using MS Ajax Minfier 4.0 for Asp.Net MVC 2.0?

I am planning to use MS Ajax Minifier with Asp.Net MVC 2.0 for handling the Js and Css files. Does anyone has experience with MS Ajax Minifier? I have following questions regarding this.
Is it the best way to use JS/CSS files in Asp.Net MVC or is there a better way. E.g. YUI Compressor, Telerik Extension for MVC?
As I understand we can use this to convert SomeFile.js to SomeFile.min.js at the build time. However In my mvc Views I still have the Script reference pointing to SomeFile.js. How does the browser will pick the SomeFile.min.js file?
It's one possibility to use. The integration when building is a nice asset and it has hypercrunching.
You must use the SomeFile.min.js in your script reference. But in Visual Studio you can have an uncompressed file with this name SomeFile-vsdoc.js for intellisense coding (in which you can also use xml comments which will be picked up by VS.
Another approach would be to use SquishIt.
Grz, Kris.

ASP.NET MVC without ASP.NET?

As far as I know, ASP.NET MVC leverages a lot of the features of ASP.NET Web Forms, one of these services is how to get the Html response from the template .aspx file (the view). Can asp.net mvc leverages any other platform to generate html over template files (something like PHP for example)?
EDIT: There is NO use case for this, just curiosity!
Yes, it can! The aspx model is just one of the view template mechanisms. There are others - you can even write your own. The key here is IViewEngine, with WebFormViewEngine being the aspx/ascx provider. ASP.NET MVC In Action covers some of this in chapter 6 "Customizing & Extending the ASP.NET MVC Framework".
you can use other ViewEngines
Spark
NHaml

Hybrid WebForms/ASP.NET MVC [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
ASP.NET MVC alongside Web Forms in the same web app?
I am kinda new to .NET applications, I have a web forms application that I am working on and I am about to start the development of new pages, I am trying to make the new pages with the ASP.NET MVC, but I am not beeing able to make the pages hit the controllers. First i added the library references added the routes on the global.asax but not sure what else is missing, can someone help me out?
thx.
Reading between the lines I gather you are trying to add MVC pages to your existing ASP.NET Webforms Webapplication?
If that is the case then you probably need some MVC specific config. settings. Easiest way is to create a new MVC web app and then merge the config settings.
Furthermore if you are doing a hybrid project I'd recommend giving Scott Hanselmann's post on the topic a read.
There's a more step-by-step description of adding MVC to a WebForms Application at these links:
Integrating ASP.Net MVC Into An Existing ASP.Net Web Application
Mixing ASP.NET Webforms and ASP.NET MVC
You might also want to add the ProjectTypeGuid to the project file with a text editor ({603c0e0b-db56-11dc-be95-000d561079b0} is used to designate to Visual Studio to use the MVC extensions.)
<ProjectTypeGuids>{603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
The links above also don't fully cover the system.webserver area of web.config that needs to be configured.
Scott Hanselman released a "totally unsupported" Nuget package that adds MVC 3 features to an existing Web Forms project. It also works on my PC (ha ha) and I've used it on several projects.
http://nuget.org/List/Packages/AddMvc3ToWebForms
He blogged about it here:
http://www.hanselman.com/blog/CreatingANuGetPackageIn7EasyStepsPlusUsingNuGetToIntegrateASPNETMVC3IntoExistingWebFormsApplications.aspx
One newb tip: this package will configure your MVC routes in /App_Start/RegisterMvc3Routes.cs
I've spent a lot of time over the past few months on this. Here are my observations.
The good/easy
- Getting Webforms to call into MVC controllers
- It was remarkably easy to stand up a new MVC3 project and drop Webforms pages into it.
- I was able to move my <pages><controls></controls></pages> section into the /pages directory in a new web.config there
The dirty/difficult
Regarding the GUID
Please note that the GUID has to be added at the front of the line for some reason... everytime I tried it failed. Until I stumbled on a post that insisted it be the before the others.
also I don't know what the difference is but I have a different GUID working... {E53F8FEA-EAE0-44A6-8774-FFD645390401}
getting the landing page to be Webforms caused ALL kinds of snags.
getting jQuery intellisense to play nicely with T4MVC
this is what I did to address that
#if (System.Diagnostics.Debugger.IsAttached)
{
<script src="../../Scripts/Mvc3/jquery-1.7-vsdoc.js" type="text/javascript"></script> #* intellisense! *#
#Html.RelativeJavascript(Links.Scripts.Mvc3.jquery_1_7_js)
#Html.RelativeJavascript(Links.Scripts.Mvc3.jquery_unobtrusive_ajax_js)
}
else
{
#Html.RelativeJavascript(Links.Scripts.Mvc3.jquery_1_7_min_js)
#Html.RelativeJavascript(Links.Scripts.Mvc3.jquery_unobtrusive_ajax_min_js)
}
Recommendations:
Use T4MVC in ALL cases even if you are pure webforms. The elimination of magic strings for static content (.js,.css, images, specifying templates) is outstanding.
and if you have any part of your build process compiling views then you get compile-time safety on any of those links.

Resources