Can Server .html Files Using Razor As If They Were .cshtml Files Without Changing The Extension Of All My Pages
Feb 24, 2011
I manage a large asp.net site which has previously been converted from static html site to asp.net. For several reasons (mainly SEO) we decided not to rename all the files to .aspx back when we originally converted the site. This was very easy to do by simply adding the buildProvider and httpHandler to the web.config.
Now I am upgrading the site to use Asp.net WebPages with Razor cshtml files. I can rename all the files if necessary, and use url rewriting to make the urls stay the same, however it would be much easier if I could just configure the web.config to tell it to parse .html files as if they were .cshtml. I have searched around quite a bit, and could not find anything equivalent to the PageHandlerFactory for razor pages. It appears as though it is just an internal mechanism in the .net 4.0 ISAPI handler.
The site is currently running on Windows 2003 server and IIS 6. We will be upgrading to 2008/IIS 7.5 in the near future, but I'd prefer not to wait for that. Is there any way to get the .html files to be parsed by razor as if they were .cshtml files?
I get the error message The system cannot find the path specified for a .html file that doesn't exist on the server.
1. Is it possible to set up an error page for .html pages that doens't exist without having access to IIS.
2. If you need to do it in IIS, can you do this for .html files, and then set up custom error pages for .aspx files in the web.config so that these rules co-exist.
Following the first site, it had worked but when I´ve moved the pages and files to other folders and set the web.config file on this folder, now it won´t work at all!!!
The file is an *.swf object. I did put the asapi.dll to map the extension on the website root, I´ve put the
[Code]....
on the web.config new folder and on the web.config website´s root.
It won´t work!!! I can access the file directly!!! on the web.config of the folder that contains the file, there is a <deny users="*" /> line.
I'm doing something wrong, but for the life of me can't figure out what. (Maybe it's all the beta software I'm using to build this website ;-) )I'm trying to use the Facebook helpers, which use the WebMatrix.Data and WebMatrix.WebData libraries. These work fine from my class files, but apparently I can't use them in my .cshtml files.Anybody run into this? Alle references to classes in these libraries break my site (not my build btw?). And yes, they are referenced.
Now i am learning mvc3 razor. I create a razor mvc project and set a vitural webapp in IIS7 for it , as "localhost/mvc3/". When i do some changes on .cshtml trying to check effects I just find that corresponding page doesn't change even refresh browser. I am not quit familar with the rule & principle on this.
BTW : this post page seems have severe problem because I cannot use the message editor in Chrome / IE9beta : they just leave a stubborn blank area for me.
When I initially created my SQL Express 2008 database I vastly over-estimated the size of my database files. The problem is that now I have the correct field sizes and data actually in the database it does not require the max file sizes and growth that I had originally set.
This is a problem as I have a max database size of 500Mb with my web hosting provider and it appears that my database now has too large a footprint. This is after I have used the shrink database command in SQL Server Management and shrunk the database to a size of 6Mb so I can only presume that the problem lies with the fact that my original file size / growth settings are taking my database size to well over the 500Mb threshold I am permitted.
Is there anyway for me to change the max file size and growth options of my database without having to recreate the database from scratch?
I am not sure this is the forums but I dont know where to write this and this is an EMERGENCY ::I had windows 2003 server. on C: and I have installed windows 2008 server.I had SQL server installed and all of the database files stored inside c:program filessql server....PROBLEM is that after I installed 2008 server I can see 2 folders of program files one for x86 and the other for 64 bits.
I have a form with 10 file inputs. They can contain 10 random files with random sizes. If I send these files to ASP.NET server with this code:
var count = HttpContext.Current.Request.Files.Count; var TotalSize = 0; for (int i = 0; i < count; i++ ) { HttpPostedFile postedFile = HttpContext.Current.Request.Files.Get(i); TotalSize += postedFile.ContentLength; }
And as you can see I didn't save the files on the server, will this code just calculate the summary of files without need to receive the whole file from the client (And therefore it would be very fast)?
I am trying to open different types of files that I have uploaded on my sql server database. I would like to display all the list of files in Gridview. When user click the link it should open download dialog box and should be able to open its particular applications such as word, excel, browsers etc.
I am using the Directory.GetFiles method as follows:
[Code]....
As expected, it returns files with the ".pdf" extension. I would like to be able to specify more than one extension (like "*.doc*" and "*.txt*", etc.). How can I use GetFiles to return files with more than one desired extension, without returning all files?
In the default ASP.NET MVC 3 project, layout & partial cshtml files start with an underscore (eg. _viewstart, _Layout, _LogOnPartial). Why? Does the framework give some special meaning to a cshtml file that begins with an underscore?
In my application users can write their own 'templates'. That are filled with data from other sources. I could use a simple token replacement, but I would like to be able to use the Razor syntax and engine for rendering the template. Here is an overly simplified example:
[Code]....
Before you point to the following sources I will clarify what I have learned from them:RazorEngine (http://razorengine.codeplex.com/). This code compiles the string into a class, then a dll, then finally reads from a dll - all this to bypass the MVC engine. I don't want to do that because I am in MVC and don't want the additional overhead.The following blog shows how to do this for one of the MVC 3 pre-releases:http://buildstarted.com/2010/09/28/mvc-3-razor-view-engine-without-a-controller/ I cannot get it to work with MVC 3 RTM. When I take the exact code (and replace the CshtmlView with a RazorView) I end up with the error: The method or operation is not implemented. It appears to have something to do with @Model.Name, and being unable to find "Name".A comment in the blog elludes to a statement from ScottGu that the RTM would allow this functionality from the get go. I cannot find this blog.
This question appear when I worked with partial view (MVC3/Razor), but I am sure - it's clear Razor Syntax question, not related direct to partial view. So - I have partial view Menu.cshtml with full markup as:
@model IEnumerable<SportsStore.WebUI.Models.NavLink> @foreach(var link in Model) { @Html.RouteLink(link.Text, link.RouteValues); }
No problem - "parent" view call it @{Html.RenderAction("Menu", "Nav");} and all work as magic. But, if I will edit the Menu.cshtml as:
@model IEnumerable<SportsStore.WebUI.Models.NavLink> @foreach(var link in Model) { Html.RouteLink(link.Text, link.RouteValues); }
(see - NO '@' before Html.RouteLink!) all just broke: now @{Html.RenderAction("Menu", "Nav");} output is totally empty, no one HTML tag. Want to know - what is the difference between two piece of code? I assume @ before foreach also automatically "drop into" and apply to Html.RouteLink as well? So - am I wrong?
in my project i would like to save pdf files in database, how to save pdf files in database ? along with that i would like to create create a search page to search for pdf files with PDF file names , how to accoplish these things
I've been writing an app using the awesome new Razor view engine and for the most part, things have been great.
One issue I keep running into, however, is that if I should happen to write invalid code, such as referencing a null property or even a non existent property, rather than throwing an error, something happens in the background that causes the browser to wait and wait and wait and if I do not cancel the browser's request quick enough, IIS will simply hang.
It seems as if it enters some sort of loop. CPU usage goes up (though not terribly high) and restarting IIS via either GUI or iisreset command seems to take abnormally long (presumably while it waits for the process to safely shutdown).
This also happens for other invalid code scenarios such as failing to close a code block with a closing brace.
I am building a site with WebMatrix using the razor syntax in .cshtml files. However I'm stumped as to how I can use the normal set of asp.net controls that are found in the toolbox in Visual Studio - eg: calendar, panel, radio button list etc... Is it possible to use these or can you only use Helpers with razor?
I would like to use the _ViewStart page to set the master page (layout) used by the views. I have only two different layouts. One for the homepage and one for the other pages (but that may change)I was hoping to add a dynamic property to the ViewModel object in the home page's controller method and then check for it. Something like this_ViewStart =
I basically want to do a reverse 'search in all files', so it returns files that don't contain "keyword".Does anyone know how to do this, or the regex used, etc?