C# - Using HttpHandlerFactory To Render CMS And Physical Pages?
Sep 9, 2010
I am in the middle of writing a CMS system and after reading and working through a few examples, I have settled on HttpHandlerFactory to perform what I need.
the key point is our sites are generally a mix of copy and registration processes. So I currently need to use the default HttpHandler for aspx to render the physical registration pages until I can work a way to content manage them too.
after creating the handler class I added the following to my website's web config
As the above path handles physical and cms driven pages, with a small check in the code I am able to see if the page physically exists and can then render the desired page.
Why does ASP.NET pages render time on Chrome and FF is ~ 3X the render time on IE ??This problem only persist on my local machine, but when published to the real server the complete opposite happens (expected, as FF and Chrome outperform IE).
I tried Windows 7 x64 and Windows XP x86 with FF 3.6, Chrome 9, and IE 8.
Is there any thing I can do on IIS or in the web config to fix this behavior ?
EDIT: In response to the responses an domments:
I don't have these issues when running PHP + apache, or JSP I noticed this behavior when doing a debugging session in VS or after deploying on IIS Modifying the hosts file did improve Chrome and FF response time indeed, but still slower than IE !
Take the following scenario. I have multiple ASPX pages. Login, Logout, Main, Messages, etc... They all inherit from System.Web.UI.Page of course. For all the pages, I want to override the Render method from the Page class. I could easily copy and paste the same code into each page like so:
protected override void Render(HtmlTextWriter writer) { //Code Logic Here }
But if I had many pages, lets say 20, maintaining the code in each page could get very time consuming and error prone.That made me think a bit and I thought okay lets try this...override the function in each page but call a static function. That way changing the static function would result in a change for every page.Which works fine... But its not really nice and clean, having to override like that on every single page.
I've been watching a video on Scott Hanselmnn teaching MVC 2 tricks/tips. He mentions how MVC 2 by default uses ASP.NET Web Forms view engine to render the output of the views; he mentions that the web forms view engine is a little slower than it could be for MVC 2 since it generates a control tree and then outputs the HTML to the page (I hope I said that right).
I was wondering what he meant by web forms generating a code tree before outputting the HTML to the page. Does anyone have insight on the view engine of Web forms and the steps of the rendering process works for ASP.NET and MVC2?
Is there a way to get the physical filepath from an ASP.NET's URL?
Scenerio: I have an app that is on two severs, but it will now be on lots more, and each server puts it in a different physical file path. Right now I'm doing this:
//for server 1 if (Request.Url.GetLeftPart(UriPartial.Path).Contains(".com")) { Application["StoreFilesPath"] = "E:\Data\rootsite\f1\appsite\Upload\"; } //for server 2 if (Request.Url.GetLeftPart(UriPartial.Path).Contains(".net")) { Application["StoreFilesPath"] = "E:\Web\rootsite2\f34\abc\ghi\appsite\Upload\"; }
But what I need to do is something like this:
//for all servers Application["StoreFilesPath"] = getPhysicalFilePath() +"\Upload\";
i am trying to insert with bulk and getting the following
Cannot bulk load because the file "D:inetpub.........insertgid.csv" could not be opened. Operating system error code 3(The system cannot find the path specified.).
My basic question is, can a virtual directory in IIS point to a physical path that's not on the local machine? For instance, right now I have a virtual path /NaturalGasReport/NYMEX which points to physical path C:Program Files (x86)NymexSettleNATGAS_REPORTNYMEX, but I want it to point to a physical path on a difference PC on the same network. Is this possible? (I know I can just try it out so I apologize for asking but I thought it would be best to get an explanation along with "yes" or "no"). If you want more detail, this is what I need to do. To make a long story short, because of a vendor product we are using that won't run on a 64-bit operating system, I have to run a program called Generate_NGReportData.vbs (it's a vbscript program) on a PC I will call 28. It uses a vendor product which produces jpg files which are graphs of the Natural Gas market. The machine where I wish it could run is called RTEST01 but this machine runs a 64-bit OS and the components won't work there. RTEST01 has the databases. So, I created a datasource on 28 which points to RTEST01's database. The vbs program will read the data, generate the reports, and write one row to a database table on RTEST01. RTEST01 has to run the complimentary program which sends these reports (via email). 28 is not an email server so it can't email the reports. So on RTEST01 I will run Send_NaturalGasReport.vbs. This program creates an email body of html. The html references [URL]NaturalGasReport/NYMEX/" & Day(nymex_update_dt) & ".jpg which is a virtual directory pointing to C:Program Files (x86)NymexSettleNATGAS_REPORTNYMEX. I need it to point to the folder and files on 28.So if my initial question has a simple yes answer then I am all set. If not, examine my architecture and propose an alternative solution.
How would you accomplish these in ASP.NET Webforms 4.0 Routing;.aspx pages should not be accesible directly, pages should be accesible only with routes, Start page should be "/" or "/home" or something else, but not "Default.aspx".
I have a website say www.abc.com I am giving the users there own mini site with the URLwww.abc.com/website/home.aspx?UID=1
This URL will access to my Home.aspx page located in website folder and display the user information based on UID
I want to register each user with their own domain and redirect the functionality to mywww.abc.com/website/home.aspx?UID=1 page.
For example let's say when user type www.user.com user the site will be redirected to mywww.abc.com/website/home.aspx?UID=1 page but the URL of web browser will not change, user can still seewww.user.com on his web browser.
If User click about us link i.e. www.user.com/aboutus/ the site will be redirected towww.abc.com/website/aboutus.aspx?UID=1 page but the URL of web browser will not change.
I have a website say [URL] I am giving the users there own mini site with the [URL] This URL will access to my Home.aspx page located in website folder and display the user information based on UID. I want to register each user with their own domain and redirect the functionality to my [URL] For example let's say when user type [URL] user the site will be redirected to my [URL] page but the URL of web browser will not change, user can still see [URL] on his web browser. If User click about us link i.e. [URL] the site will be redirected to [URL] page but the URL of web browser will not change. I am using IIS 6 and ASP.net 2.0.
I'm running an Asp.NET MVC 2 app under IIS 6.All pages are behind Windows Integrated Authentication except for some pages that accepts anonymous access.We setup these pages in the web.config with the location element like this
this is an Asp.NET MVC app, the path indicated in the path attribute points to an action method not a physical location.When this was running under IIS 7 integrated mode it was working fine. But when we switched to IIS 6 we get the login prompt even with the pages that are set to accept anonymous users.ow to make IIS 6 authorize anonymous access to non physical paths ?
I've set up IIS7 on my home computer and have written a very basic ASP.NET website to be deployed on this webserver. Everything works great. How do I determine programmatically the physical path (for instance, "C:inetpub_MyWebsite") of the website? I need to write an XML file to the website's root folder dynamically and therefore need to know the folder's physical location.
I use ASP.NET routing to rename the full paths of my URLs (ie. /page1/page2/file.aspx would just become /file.aspx). This doesn't work with web.config authorization, because that uses physical path/folder names.
I'm getting tired figuring out this error. Well, Basically. I have uploaded my ASP.net website to a server (IIS installed) as well as the VB project I made.
BOTH are connecting to a DB named CLIENTS.
the website uses a datagrid to show data, while the VB Project updates the DB based on a monitored folder.
The Problem is If the website is opened first the VB project shows an error "Unable to open the physical file (MDF). Operating system error 32 (error not found)" and Vice Versa if the VB project is first started.
I have copied a DB from one my computers and using it here. On trying to open the page which requires the fetching content from DB, on con.open I am getting this exception:
Unable to open the physical file "E:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATAcakephp.mdf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".
In Visual Studio, when I test the connection, it says "Test connection succeeded". However, there is one strange thing going on. When I login to the Management Studio, there is no + sign with the newly attached database, as shown.
We have several virtual applications inside one main (root) application. How to share Cache between this virtual application and main application if they are located (and always will be) on the same physical machine? By Cache i assuming System.Runtime.Caching or System.Web.Caching. Hope that i do not need to setup AppFabric Caching for this...
I've found myself having a requirement to configure log4net based on a file relative to the physical location of the running ASP.NET web application. We like to start the logger as early as possible, so Application_Start seems a proper place. In IIS6, this works fine and has been running for ages, but now we moved to IIS7 and this won't work anymore:
because the HttpContext.Current is not available in many global.asax (Application, Session) events. This is old news, we all know it raises the now infamous Request is not available in this context error. We don't want to move back to Classic Mode.
Now, the question is simple: without using HttpContext, is it possible to find the physical location of the currently running web application instance?
I'm trying to get my company to move to ASP.NET MVC and away from classic ASP. I've written some sample applications as proof-of-concept but now I'm running into problems as I try to deploy these mvc applications to my company's IIS7 server. My System Administrator says that there is something in ASP.NET MVC that is preventing him from having a UNC path specified as the server's physical path to the site folder. This sounds ridiculous to me because (to my knowledge) the MVC Framework doesn't have any effect on this setting... nor does the code I write. The bottom line is this: if any of my mvc applications are to be used for clients, they have to run on a server using a UNC physical path. Currently, the mvc apps will work when the server has a non UNC path... just not with a UNC path.
Am I wrong to tell the System Admin that it isn't MVC that's mucking up his UNC paths? Is there I resource you guys know of that I can use to research this problem? Edits:
The error that is showing up in the browser says:
Security Exception
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
And the Stack trace showed: [SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean ignoreCase) +0 System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +42 System.Web.UI.Util.GetTypeFromAssemblies(ICollection assemblies, String typeName, Boolean ignoreCase) +145 System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) +73 System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) +111 System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) +279
Basically I want to JOIN a table from a MySQL database to a table from a MSSQL database. The reason is because I don't own the MySQL database and I only have SELECT privileges to it. For my ASP.NET application, I need to create two new tables. I have my own MSSQL DB and I have an SA account for it. Is this possible? This is how I connect to MySQL:
[Code]....
I think the problem here is that I need 2 open database connections for the DataAdapter to use?