中の技術日誌ブログ

C#とC++/CLIと
VBと.NETとWindowsで戯れる
 

目次

Blog 利用状況

ニュース

自己紹介

東京でソフトウェアエンジニアをやっています。
お仕事大募集中です。
記事執筆や、講師依頼とかでも何でもどうぞ(*^_^*)
似顔絵 MSMVPロゴ
MSMVP Visual C# Since 2004/04-2013/03

記事カテゴリ

書庫

日記カテゴリ

00-整理

01-MSMVP

ASP.NETでInProcを使ってはいけない

この文書の最新版は
http://naka.wankuma.com/site/column/aspnet/00012.htm


この文書はVisual Studio 2005 TSかTE for SD(.NET 2.0)をベースに記述されていますが、Visual Studio 2002から同じことです。

ASP.NETをプロジェクトとして取り組んでいる方は、"あなたのプロジェクトはセッションモードをどうしますか?"と聞かれて即答できますか?

Visual Studio 2003のWeb.configを見てみましょう。

<!--  セッション状態の設定
      既定では、ASP.NET は Cookie を使用して、要求がどのセッションに属するかを識別します。
       Cookie が使用できない場合は、URL にセッション識別子を入力することで、セッションを見つけることができます。
      Cookie を有効にするには、sessionState を cookieless="false" に設定してください。
-->
<sessionState 
        mode="InProc"
        stateConnectionString="tcpip=127.0.0.1:42424"
        sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
        cookieless="false" 
        timeout="20" 
/>

このように定義されています。

Visual Studio 2005ではWeb.configデフォルトで存在しないので、C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\CONFIG\web.config.comments
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config.comments

にデフォルト設定のコメントがあります。

<sessionState mode="InProc" ~略~ >

どちらもデフォルトはインプロセスモードということです。これはASP.NETが実際に稼動しているプロセス(プログラム)の内部に値を保持するという意味です。

ここでひとつ確認をして見ましょう。

このようにラベルとボタンだけをおきます。

ボタンのコードに以下のようなものを用意します。

C#
protected void Button1_Click(object sender, EventArgs e)
{
  if (Session["cnt"] == null)
  {
    Session["cnt"] = 1;
  }
  else
  {
    Session["cnt"] = (int)Session["cnt"] + 1;
  }
  this.Label1.Text = ((int)Session["cnt"]).ToString();
}

ボタンを押すと数字が数がカウントアップするサンプルですね。

うまく言っていることを確認します。

ここで、ASP.NET構成の設定で何かを変更してみましょう。

適用した後に、もう1度ボタンを押して見ましょう。

1になってしまいました。これはなぜでしょうか?

PRB: ASP.NET InProc セッション状態モードを使用すると、 Session Data が失われます。
http://support.microsoft.com/kb/324772/ja

[PRB] ASP.NET アプリケーションで断続的にセッション変数が失われる
http://support.microsoft.com/kb/316148/ja

Why does App restart? (FAQ)  ←うにさんの日本語情報です
http://www.hollytown.net/uniblog/Comment/2005/02/18/0878.aspx

ASP.NETというレベルで見ると、これらの情報のとおり再起動したほうがいいと思ったタイミングで再起動されます。

うにさんのページには無いのですが、2.0の環境では内包ディレクトリを削除すると再起動されるようです。

また他にはIIS6(Windows Server 2003、Windows XP x64 Edition)には別途アプリケーションプールと言う考え方があります。

これらは設定次第で、分ごとやメモリの大量消費の都度自動的に再帰動します。

ASP.NETのアプリケーションは時にに大量の要求をこなす圧力にさらされています。時に大量の一時メモリを利用する圧力にさらされています。

これらの要求にこたえるためにも再起動は必要なのです。

さて、InProcからStateServerやSQL Serverに変更した場合に問題になるのは何でしょうか?

  1. シリアル化可能であること
  2. Session_OnEndイベントが発生しないこと

おもにこの2点に注意しておけば大丈夫でしょう。

参考リンク
http://forums.microsoft.com/msdn-ja/ShowPost.aspx?PostID=274821&SiteID=7

投稿日時 : 2006年3月16日 12:48

コメントを追加

# アプリケーション・リスタートのタイミング 2008/06/10 0:03 のんびりゆこうよ@わんくま同盟

アプリケーション・リスタートのタイミング

# アプリケーション・リスタートのタイミング 2008/06/10 0:11 のんびりゆこうよ@わんくま同盟

アプリケーション・リスタートのタイミング

# re: ASP.NETでInProcを使ってはいけない 2017/12/01 15:30 kissanime

このような有益な情報をここで共有してくれてありがとう

# LvtpsgapUYefKz 2018/08/16 8:49 http://www.suba.me/

MGJl7w Really informative blog.Really looking forward to read more. Awesome.

# nFHdVqCDipLqoKj 2018/08/17 20:50 http://www.etihadst.com.sa/web/members/stampgeorge

Lovely just what I was looking for. Thanks to the author for taking his clock time on this one.

# CWmSMFhgXLkHIyQS 2018/08/17 21:28 http://hotcoffeedeals.com/2018/08/15/gst-registrat

Im obliged for the article.Really looking forward to read more. Much obliged.

# YAHXBtEOFCZlCId 2018/08/18 0:49 https://locallandscaper.wordpress.com/2018/07/28/j

you! By the way, how can we communicate?

# LnwHAjZBGYoP 2018/08/18 5:52 http://demos.gamer-templates.de/specialtemps/clans

several months back. аАТ?а?а?For our business it as an incredibly difficult time,аАТ?а?а? he was quoted saying.

# vnCIRtryxKHc 2018/08/18 6:18 https://www.amazon.com/dp/B073R171GM

This awesome blog is no doubt awesome additionally informative. I have chosen helluva helpful things out of this amazing blog. I ad love to go back again soon. Cheers!

# puotFpptbYEXXJg 2018/08/18 14:20 http://www.bookmarkiali.win/story.php?title=free-c

Very clear internet site, thanks for this post.

# ENNfrBeRuefxEkibZvH 2018/08/18 15:24 http://2016.secutor.info/story.php?title=prodvizhe

The political landscape is ripe for picking In this current political climate, we feel that there as simply no hope left anymore.

# jRrDLQMuTVcHdnyx 2018/08/18 22:50 http://adisker-metodist.kz/?option=com_k2&view

Really appreciate you sharing this blog. Much obliged.

# eelwWkzlzhNJ 2018/08/19 1:57 http://demo.socia.us/blog/view/7591/how-you-can-ge

Outstanding post, I conceive people should learn a lot from this site its very user genial. So much superb information on here .

# sMdiHuwYGgZT 2018/08/19 2:31 http://news.bookmarkstar.com/story.php?title=ghe-s

It as really very complicated in this active life to listen news on Television, thus I simply use web for that purpose, and get the latest information.

# bRAGUxJdUonomMKB 2018/08/19 3:07 http://news.bookmarkstar.com/story.php?title=doc-t

I think this is a real great blog.Thanks Again. Awesome.

# XjATgpVFLbmMGOiOM 2018/08/20 15:33 https://www.yelp.co.uk/biz/instabeauty-cambridge

It as the little changes that make the biggest changes. Many thanks for sharing!

# svHgovfDNJDFAze 2018/08/21 17:02 https://kyanmoreno.de.tl/

Very neat article post.Much thanks again. Much obliged.

# GRaZwgbcOVIxbezgxrC 2018/08/21 17:29 http://www.experttechnicaltraining.com/members/bro

The best approach for the men which you can understand more about today.

# mBcIBvgzKtzzhdCAsB 2018/08/21 17:54 http://aixindashi.org/story/1072518/

Wow, awesome blog structure! How long have you ever been blogging for? you make blogging glance easy. The whole look of your web site is fantastic, as well as the content material!

# DoUnVwMBYHmywdNSawc 2018/08/21 18:49 https://disqus.com/home/discussion/channel-new/spy

I think this is a real great blog post.Much thanks again. Great.

# rkOgDNhZJPwYjrmX 2018/08/22 1:08 http://dropbag.io/

Yeah bookmaking this wasn at a bad determination outstanding post!.

# uVVmjXKaxXYF 2018/08/22 2:32 http://www.goodirectory.com/story.php?title=most-c

You made some first rate factors there. I seemed on the internet for the difficulty and located most individuals will associate with together with your website.

# fOjorDnuRyqvDJ 2018/08/22 3:51 http://seoworlds.ga/story.php?title=to-read-more-1

Wow, this paragraph is fastidious, my sister is analyzing these things, thus I am going to tell her.

# azlooWVwbCXzPGNKQwf 2018/08/23 0:30 http://blogcatalog.org/story.php?title=kickboxing#

It as nearly impossible to find well-informed people for this topic, however, you sound like you know what you are talking about! Thanks

# gUcPVAdTXVEbDZ 2018/08/23 0:52 http://inclusivenews.org/user/phothchaist317/

I was suggested this blog by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my problem. You are wonderful! Thanks!

# LvEYZacyTEYbKny 2018/08/23 13:43 http://5stepstomarketingonline.com/JaxZee/?pg=vide

My brother recommended I might like this blog. He was totally right. This post actually made my day. You can not imagine simply how much time I had spent for this info! Thanks!

# UkJnRVQVcZCXZqUBD 2018/08/23 18:39 https://www.christie.com/properties/hotels/a2jd000

Very good article post.Really looking forward to read more. Fantastic.

# AfpqwvfDUSLuUd 2018/08/23 21:09 http://adsposting.cf/story.php?title=agen-sbobet-2

I went over this site and I conceive you have a lot of great info, saved to bookmarks (:.

# ojZFwGCpRnKyUKhdf 2018/08/24 2:10 http://voroniny.org/user/sesinemnbeeno924/

I truly appreciate this blog post.Much thanks again.

# tdAYAvGGGlywIxtQlO 2018/08/24 16:04 https://www.youtube.com/watch?v=4SamoCOYYgY

Just Browsing While I was surfing today I saw a great article about

# XTiaidikeywzAErJx 2018/08/24 18:39 http://gozeworkout.services/story.php?id=35149

There is certainly a lot to find out about this subject. I like all of the points you have made.

# yOkekAwjJHuo 2018/08/27 17:28 https://kidblog.org/class/nycextinguisherservice/p

Thanks-a-mundo for the blog article.Much thanks again. Much obliged.

# arhLctpJJGnTOCoyy 2018/08/27 20:33 https://www.kiwibox.com/wasisson/blog/entry/142358

wow, awesome article post.Really looking forward to read more. Great.

# iQVWoAwKAE 2018/08/28 0:03 https://visual.ly/users/diucratexcap/account

Major thanks for the post.Really looking forward to read more. Really Great.

# qunZqciScuWuf 2018/08/28 1:19 http://www.momexclusive.com/members/emerymelody3/a

Thanks for sharing, this is a fantastic article post.Much thanks again.

# NZxYRDjPNvTPrQEbxXz 2018/08/28 5:28 http://thewelaptop.review/story.php?id=39476

Really informative blog article. Much obliged.

# HBZjWxpeAEGbifgjc 2018/08/28 10:33 http://banki59.ru/forum/index.php?showuser=427874

your posts more, pop! Your content is excellent but with pics and videos, this site could definitely be one of the best

# zdGtyXMQsivgvrUIhKC 2018/08/28 19:16 https://www.youtube.com/watch?v=yGXAsh7_2wA

This web site definitely has all of the information and facts I wanted concerning this subject and didn at know who to ask.

# WXpVCZVivQ 2018/08/28 22:02 https://www.youtube.com/watch?v=4SamoCOYYgY

Major thankies for the article post.Much thanks again. Much obliged.

# qDbFaSffqoV 2018/08/29 1:10 http://freeseo.ga/story.php?title=for-more-info-13

This website was how do you say it? Relevant!! Finally I ave found something which helped me. Cheers!

# gQdtvVACRyPPcuf 2018/08/29 21:10 https://martialartsconnections.com/members/coffeeg

Very informative article.Much thanks again. Much obliged.

# vyYldFMZLkMo 2018/08/29 21:25 https://northcoastvolleyball.org/elgg2/blog/view/1

Really informative blog.Much thanks again. Much obliged.

# kOgnMRdzZJYqkD 2018/08/30 0:57 http://www.etihadst.com.sa/web/members/henband45/a

Really informative post.Really looking forward to read more. Keep writing.

# uWUopvkows 2018/08/30 2:55 https://youtu.be/j2ReSCeyaJY

Your style is very unique in comparison to other folks I ave read stuff from. Many thanks for posting when you have the opportunity, Guess I all just bookmark this page.

# VryqBIeuTHGwhaZ 2018/08/30 19:33 http://beardpasta6.ebook-123.com/post/finding-the-

this post reminds me of my old room mate! He always kept

# jjMLvUXOWuuilw 2018/08/31 17:06 http://newvaweforbusiness.com/2018/08/30/find-out-

Since the admin of this website is working, no

# MbFKnYaIfM 2018/09/01 12:57 http://www.umka-deti.spb.ru/index.php?subaction=us

Thanks for the blog.Thanks Again. Great.

# RWZYVrtHDzXDRFZCyCA 2018/09/01 17:05 http://job.gradmsk.ru/users/bymnApemy161

It as hard to find well-informed people for this topic, however, you sound like you know what you are talking about! Thanks

# fnYizZzvwNxHy 2018/09/02 20:52 https://topbestbrand.com/&#3610;&#3619;&am

That is a very good tip especially to those fresh to the blogosphere. Short but very accurate info Thanks for sharing this one. A must read post!

# OcKkNvQkRX 2018/09/04 18:06 http://www.ownedbusinesssolutions.net/blog/view/14

You should not clone the girl as start looking specifically. You should contain the girl as design, yet with your own individual distinct distort.

# RuVabfogvRCoItwOuAO 2018/09/05 17:28 https://issuu.com/lisdicmicma

Thanks so much for the blog article.Really looking forward to read more. Want more.

# FJXWsOdKCuQDZNVUxS 2018/09/05 18:31 http://bookmarkuali.win/story.php?title=bigg-boss-

This is a very good thing, is your best choice, this is a good thing.

# UlwctIpIjwqA 2018/09/06 13:31 https://www.youtube.com/watch?v=5mFhVt6f-DA

terrific website But wanna state which kind of is traditionally genuinely useful, Regards to consider your time and effort you should this program.

# oIfSYFBkTYSBcUJyAz 2018/09/06 16:47 https://jokefrost8.bloguetrotter.biz/2018/09/04/po

Wow, marvelous blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is magnificent, let alone the content!

# gvkkYEmKroYqZvc 2018/09/06 19:34 https://martialartsconnections.com/members/cratest

Just read this I was reading through some of your posts on this site and I think this internet site is rattling informative ! Keep on posting.

# Fantastic beat ! I wish to apprentice even as you amend your website, how could i subscribe for a blog site? The account helped me a applicable deal. I were tiny bit familiar of this your broadcast provided shiny transparent idea 2018/09/08 14:13 Fantastic beat ! I wish to apprentice even as you

Fantastic beat ! I wish to apprentice even as
you amend your website, how could i subscribe for a blog
site? The account helped me a applicable deal.
I were tiny bit familiar of this your broadcast
provided shiny transparent idea

# HnZGooYjfaWyiEPkjo 2018/09/10 19:23 http://animesay.ru/users/loomimani757

information in such a perfect manner of writing? I ave a presentation next week, and I am at the

# ggsDfHhYMzVBCq 2018/09/10 20:01 https://www.youtube.com/watch?v=5mFhVt6f-DA

What a funny blog! I truly loved watching this humorous video with my family unit as well as with my friends.

# KRDmRMRRbiBxJlPoO 2018/09/10 22:32 https://www.flickr.com/people/partiesta/

There as definately a great deal to find out about this topic. I really like all the points you have made.

# XPrhJXlZwsaipe 2018/09/12 2:26 http://www.bronwenmcclain.sitew.org/#Restaurant.A

Sac Lancel En Vente ??????30????????????????5??????????????? | ????????

# EQTMRHzsWAAoEw 2018/09/12 15:54 https://www.wanitacergas.com/produk-besarkan-payud

I really liked your article post.Much thanks again.

# crbtWRtVQhUwdlvp 2018/09/12 19:08 http://traveleverywhere.org/2018/09/11/buruan-daft

wow, awesome blog article.Much thanks again. Fantastic.

# ETwdmTPfVwEeUyyRsoH 2018/09/13 1:29 https://www.youtube.com/watch?v=5mFhVt6f-DA

This particular blog is really cool additionally amusing. I have found helluva handy advices out of this source. I ad love to visit it over and over again. Thanks a lot!

# RKakHXSuXTcCqHqqzQ 2018/09/13 14:39 http://bgtopsport.com/user/arerapexign818/

This is a topic that as close to my heart Cheers! Exactly where are your contact details though?

# XiPgaYBFld 2018/09/13 22:05 http://factscsh.com/UserProfile/tabid/81/userId/45

Spot on with this write-up, I absolutely feel this amazing site needs far more attention. I all probably be returning to read through more, thanks for the information!

# RnBgwVJaObOQtID 2018/09/15 3:41 http://caldaro.space/story.php?title=ezvitalityhea

Perfectly composed articles , thankyou for selective information.

# tInxvtMKpQGOYV 2018/09/17 18:03 https://trunk.www.volkalize.com/members/frostcocoa

This is a excellent blog, and i desire to take a look at this each and every day in the week.

# mXVPRpEWZe 2018/09/17 23:59 https://www.scribd.com/user/425599900/teoterderia

It'а?s really a great and helpful piece of info. I'а?m glad that you just shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.

# gyNXtnfzIKJ 2018/09/18 0:19 http://www.cerne-tec.com.br/wiki/index.php?title=T

What kind of things can not circulate through the network.

# MZnTWFxjjZkCH 2018/09/18 2:58 https://iceworldweb.wordpress.com/2018/08/27/live-

Read, of course, far from my topic. But still, we can work together. How do you feel about trust management?!

# SPWnkkwHLSpnqiZbxWA 2018/09/18 3:20 https://1drv.ms/t/s!AlXmvXWGFuIdhaBfDe76Z8rS34XnxA

pretty useful material, overall I think this is worthy of a bookmark, thanks

# xAeLrxVsaqHIPyFa 2018/09/20 3:50 http://affiliate-marketing23.my-free.website/

So that as one So that tends to move in the corner. Adam compares the three big players, michael kors handbags,

# tgdrtybPkLhDPS 2018/09/20 9:29 https://www.youtube.com/watch?v=XfcYWzpoOoA

Wonderful blog! I found it while surfing around on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I ave been trying for a while but I never seem to get there! Appreciate it

# xRFhsFcndBbOw 2018/09/21 14:26 https://www.pinterest.co.uk/exenopsum/

wow, awesome article post.Really looking forward to read more. Great.

# IdFATerwAAlS 2018/09/21 15:53 https://www.liveinternet.ru/users/guthrie_fernande

Thanks for helping out, superb information.

# QQxZQndBbvY 2018/09/21 19:00 https://www.youtube.com/watch?v=rmLPOPxKDos

Very good blog post. I absolutely love this site. Thanks!

# TiXcmHkltfJG 2018/09/21 20:58 https://flarecrook7.bloguetrotter.biz/2018/09/20/s

Spot on with this write-up, I absolutely feel this site needs a lot more attention. I all probably be returning to read more, thanks for the info!

# yquEbGEzFAteGOaEGAa 2018/09/24 21:35 http://nicegamingism.download/story.php?id=39534

Wow, great blog post.Thanks Again. Really Great.

タイトル  
名前  
URL
コメント