May 2009 - Posts

IE has layout and resize height/width Problem

IE as a browser have an awkward principle. Every element that has height or width Will responsible for it's own Size.

Not inherit from it's parent. So if you set height or width it will marked as HasLayout=true.

Now the Browser will try to force Fixed the size in the layout.

Microsoft also said this is the cause of 99% of the more common IE rendering bugs/errors (disappearing, shifting elements)

this property is set to False by default, and once it is set to true, either by element type or a specific CSS property, it cannot be "reset" to false 

Internally, having layout means that an element is responsible for drawing its own content

What can trigger it?

  • position: absolute
  • float: left|right
  • display: inline-block
  • width: any value other than 'auto'
  • height: any value other than 'auto'
  • writing-mode: tb-rl
  • overflow: hidden|scroll|auto
  • position: fixed
  • min-width: any value
  • max-width: any value other than 'none'
  • min-height: any value
  • max-height: any value other than 'none'

How to reset it?

  • width, height (to 'auto')
  • max-width, max-height (to 'none') (in IE 7)
  • position (to 'static')
  • float (to 'none')
  • overflow (to 'visible') (in IE 7)
  • zoom (to 'normal')
  • writing-mode (from 'tb-rl' to 'lr-tb')

Another thing to consider is how “layout” affects scripting. The clientWidth/clientHeight properties always return zero for elements without “layout.”

*Siggh*$^%#$)

When resizing the height of an element . the Outer one still preserve the old one Height.

 In order to Make the outer one resize , try on javascript setting the problem element = element.style.zoom = 0;

Share this post: | | | |
Posted by cipto with no comments
Filed under:

My Aspx Page call Twice

You could experienced the same like me. It is because you set the aspimage or just <img src="" runat="server">

So if you set the  image source to nothing Fire fox will append to attribute  and set the src to your aspx page ex:http/localhost/mysite/mypage.aspx.

and it will try to get the image request to your aspx page.

If you see the second request header is asking for Image type

so the solution is add a dummy url if it's empty

Share this post: | | | |
Posted by cipto with no comments
Filed under:

How to build MoreScalable Web application with Asynchronous Programming

On my way of learning i read 2 article on these on MSDN magazine. Now this is really opening my eyes , giving me more enlighment. I know this before.

Don't know why when i look at it again today i grasp the understanding. Another article suggest us to carefully design and use this,when tested with stress tool you can see it also add overhead.

So use this Only for certain candidate for long length IO, Ex: webservicecall, Database access and other long process.

First let's understand  How asp.net works for each request.

apppool

For each domain there's application pool . which initiate app and module and supply it for the each request. each request has it's own application and module. The size of this application pool is the same as your threadpool Default is 25.so by default, up to 25 requests per worker process can be processed concurrently, each with its own app and module set

<processModel enable="true" 
•••
maxWorkerThreads="25"
maxIoThreads="25" />
IIS 6.0 supports application pools, which are groupings of applications
that will share a single worker process, now named w3pwp.exe.
Application pools give you the option of having as many distinct worker
processes as you want on any given server

After that let's understand How the synchronous Process of your Aspx page.

Difference of sync and async

On synchronous page, it goes through the application cycle as usual. Imagine that you load a large bulk of data, or calling webservice which all of them is IO operation and took a while.

So the thread is used all the time till it finished , after finished it will return to the thread pool.Now how about on the heavy traffic scenario. if there's no available thread from threadpool it will throw server is busy.

Yes you can increase your worker process but that's going to be a temporary relief, increase hardware also. how about on our application? is there something that we can do. I Thought you never asked.

On Asynchronous Processing. The request come and then execute the beginasync operation and The Thread goes straight back to the Pool.

When the job is finished Asp.net Get another thread launch the endcallback and execute the lifecycle event PrerenderComplete to Render(on web form)

look at this picture

AsyncModel

  • On Webform you can use the 

AddOnPreRenderCompleteAsync(new BeginEventHandler(BeginAsyncOperation),new EndEventHandler(EndAsyncOperation));

You can get the complete Finished result on PrerenderComplete Event

 

  • As for httphandler you can implement IHttpAsyncHandler.

 

  • For httpmodule
public void Init (HttpApplication application)
{
application.AddOnPreRequestHandlerExecuteAsync (
new BeginEventHandler (BeginPreRequestHandlerExecute),
new EndEventHandler (EndPreRequestHandlerExecute)
);
}

 

Now this lead us to a more scalable aspx and httphandler

Detail.

I've done a stress Test with LoadTest from VSTS.

1000 User,Browser Ie6,Ie7,FF3,Connection T3

The result is 

With Async Page its 433 req/sec, avg pagetime 36.0 sec.

With Out Async Page 392 req/sec avg pagtetime 40.1 sec.

 

 

Share this post: | | | |
Posted by cipto with 1 comment(s)
Filed under: