Showing posts with label iis. Show all posts
Showing posts with label iis. Show all posts

Tuesday, October 20, 2009

Cool web app client for SVN repository

I've been searching for an easy to use, web client for SVN repositories. I had come across svnwebclient from Polarion, and it seems very promising, useful, with lots of features e.g. compare, diff, changeset, etc., but it requires a Java Container. I'm familiar with Tomcat which is free, so I installed it on it but performance wasn't great and Tomcat was using nearly 40% of CPU on a quad core when it was busy. I didn't venture with Jetty since the docs are horrible. I played with WebLogic a while ago, but purchasing that is not an option now. I looked into glassfish from Sun, downloaded and installed it. The installation was smooth, it even has a very nice web management tool for the server. However, when i deployed svnwebclient it caused the server to be unresponsive and was using 350-450mb of memory, so again performance was bad, so I abandoned that route.
"glassfish v3 preview" docs: http://docs.sun.com/app/docs/doc/820-7689/aboaa?a=view

Screenshots of svnwebclient  from Polarion:
Online Subversion file comparison screenshot
Compare SVN Files

Subversion repository browser screenshot
Subversion repository browser


This made me look at other web clients running on other frameworks, and so I found websvn, which runs on php. I tried installing it on my personal windows vista home premium x64 OS and found it was surprisingly easy to install. However, I was really frustrated with windows vista, absolutely horrible for doing any sys admin type of work, e.g. "run as" context menu has been removed, remote desktop has been removed, all menus, shortcuts, control panels have been re-arranged and so many more issues with it, which is another story.

Here's the installation instructions for websvn on a windows box (in my case IIS 6):

1) Go to http://php.iis.net/ and click on the install to initiate the "Web Platform Installer" program, which will download a ~15mb file to set up php on IIS 6/7. Below is the actual download location:
http://windows.php.net/downloads/releases/php-5.2.11-nts-Win32-VC6-x86.msi 

2) that program should setup the IIS mapping for .php extension. which should be mapped to the fastcgi extension, in my case it was located at c:\program files (x86)\PHP\php-cgi.exe.

3) Now simply copy and paste the contents of the websvn web app into an IIS virtual directory and convert that directory to an IIS app

4) finally, copy the file c:\inetput\wwwroot\websvn\include\distconfig.php and paste it as config.php. Read thru the contents of that file and change the necessary parameters to reference your SVN service

That's it.

Links for PHP on IIS 6 or 7:

Sunday, October 11, 2009

How to prevent certain file types from being served by IIS


How to prevent certain types of files from being served by the server (IIS)?


1)       In web.config, under the httpHandlers section (which is under system.web section, add the below:
<add verb="*" path="*.blah" type="System.Web.HttpForbiddenHandler"/>
2)       Using the IIS managment console, add a new application extension mapping for *.blah
a.        Go to IIS control panel
b.       Expand the webiste, go to the desired web app using the IIS mngment console, e.g. it may be located at c:\inetpub\wwwroot\MyWebApp1
c.        Go to the properties of that webiste
d.       Go to the "Directory" tab
e.       Click the "configuration" button, this should open up a new dialog window
f.         Copy the executable path (dll) for the .aspx mapping, usually located at:
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
g.        Click on "add" button to add new type of mapping for our file type, e.g. *.blah
h.       Paste the dll location for the aspnet engine(handles aspx pages)
i.         type ".blah" (without the quotes) in the extension text area (this can be replace with any file extension eg: js/html/PDF)
j.         while still in the "add/edit application extension mapping" window click the "limit to" radio button and type "GET,HEAD,POST,DEBUG"
k.        ensure that the "script engine" radio button is selected but not the "verify the file exists" radio button



asp.net - How to add an HttpHandler to replace a folder or page

Lets say you wanted to replace the static config.xml file from a certain folder in your web app with some dynamically served data. For example, custom config xml based on the logged in user's role. This could be done easily with asp.net's httphandlers.
Steps:

  1. create a HttpHandler to serve your data based on who is logged in,
    For example you can use:
    Context.User.Identity.IsAuthenticated
    or Membership.GetUser()
  2. Add that httpHandler to the web.config file and specify the


    <add verb="*" path="MyWebApp1/config.xml" type="MyNS.ConfigXmlHandler" />



  3. Modify the IIS settings for your webapp (here it is MyWebApp1), usually your webapp is located in c:\inetpub\wwwroot\MyWebApp1. Using the IIS management console, find the node for MyWebApp1 and modify its properties. Add an application extension mapping for '.xml', so that the asp.net engine processes it. This way the request for xml files will be routed via the aspnet dll.
  4. asdf
  5. Caveat: Step 1 would be same for all IIS versions, but the other steps would be different based on which IIS you use, basically different from IIS5/6 with IIS7. Configure HttpHandlers in IIS,  Difference between IIS 7 integrated and classic mode
Resources:

An Intro to IIS 7 - classic mode and integrated mode

Tuesday, December 23, 2008

Comparison of JSF / Java Servlet and asp.net lifecycle and events (similarities, differences)

Asp.net applications similar to JavaEE web apps have application events, and we can configure listeners/handlers for those events.
For a Java web app, the following events can be handled by wiriing up our listeners in the web.xml file (web deployment descriptor) (Ref: http://edocs.bea.com/wls/docs61/webapp/app_events.html#177041)
1) Application startup
2) Application shutdown
3) Session creation
4) Session invalidation/passivation
5) Session level attribute added/removed/replaced
6) Servlet attribute added/removed/replaced
JSF lifecycle events for a jsf page: (Listeners/Handlers are defined as PhaseListeners)
Similar to the IIS engine which passes the aspx request to a HttpHandler in a asp.net engine, the JavaEE app container (Tomcat, JBoss, WebLogic) passes the jsf request to the JSF Servlet (FacesServlet). The FacesServlet then goes through the below lifecycle events (the PhaseListener can execute code before and/or after a phase): 
 
1) Restore_View
2) Apply_Request_Values (can process events and exit lifecycle)
3) Process_Validations (can process events and exit lifecycle)
4) Update_Model_Values (can process events and exit lifecycle)
5) Invoke_Application (can process events and exit lifecycle)
6) Render_Response
  1. Servlet Context events: 1) Servlet Context created - javax.servlet.ServletContextListener.contextInitialized() 2) Servlet Context about to be shut down - javax.servlet.ServletContextListener.contextDestroyed() 3) Attribute added - javax.servlet.ServletContextListener.attributeAdded() 4) Attribute removed - javax.servlet.ServletContextListener.attributeRemoved() 5) Attribute replaced - javax.servlet.ServletContextListener.attributeReplaced()
  2. HTTP Session events: 1) Http session activated - javax.servlet.http.HttpSessionListener.sessionCreated() 2) Http session about to be passivated - javax.servlet.http.HttpSessionListener.sessionDestroyed() 3) Attribute added - javax.servlet.http.HttpSessionListener.attributeAdded() 4) Attribute removed - javax.servlet.http.HttpSessionListener.attributeRemoved() 5) Attribute replaced - javax.servlet.http.HttpSessionListener.attributeReplaced()
For a ASP.net web application: the below lifecycle-events (in order): 
(Ref: Pro asp.net 2.0 in C# 2005 from Apress)
These events occur for every request. Here an aspx page request is discussed.
The systems/actors in action here are the IIS engine (inetinfo.exe), and the asp.net engine (aspnet_wp.exe). The event handlers/listeners are registered/defined in the global.asax file.
1) Application_BeginRequest
2) Application_AuthenticateRequest
3) Application_AuthorizeRequest
4) Application_ResolveRequestCache
5) At this stage the http request is handed off the appropriate HttpHandler, e.g. for an aspx request it is passed to the asp.net engine (aspnet_wp.exe), where the page is compiled (if necessary) and instantiated. 
6) Application_AcquireRequestState
7) Application_PreRequestHandlerExecute
8) At this stage, the appropriate handler executes the request,e.g. for an aspx request, the event-handling code for the page is executed, page rendered to HTML, i.e. the ASPX page lifecycle is executed (start, init, load, validate/control events, postback, loadComplete, preRender, saveViewState, render, unload
9) Application_PostRequestHandlerExecute
10) Application_ReleaseRequestState
11) Application_UpdateRequestCache
12) Application_EndRequest
Asp.net application events:
These events do not always occur, they are triggered by the application or code.
These are commonly used to perform app initialization, cleanup, usage/stats logging/monitoring, profiling, and troubleshooting. 
1) Application_start
2) Session_start
3) Application_error
4) Session_end
5) Application_End
6) Application_Disposed
Asp.net aspx pafe lifecycle events:
This lifecycle is executed inside the asp.net engine (aspnet_wp.exe) for each aspx page. 
1) Page_Start
2) Page_PreInit
3) Page_Init
4) Page_InitComplete
5) Page_PreLoad
6) Page_Load
7) Process Control events/postback 
8) Page_LoadComplete
9) Page_PreRender
10) SaveStateComplete
11) Page_Render
12) Page_RenderComplete
13) Page_Unload