With WCF 4.0 comes a feature where in a developer will not required to have a .svc file physically. An svc file is required for the IIS or WAS so that the servicehost can instantiate a new service using IInstanceprovider and as specfied in svc markup.This can be circumvented in .NET 3.5 by writing a UrlReWrite module in IIS. But that gives you a new set of maintainability problems. This .svc file can be a bit painful in REST based services as it violates REST principles.But in .NET 4.0, dependency on ,.svc has been addressed and look how easy it is. Whats good is this can coupled with a custom service host. Lets look at the implemenation
I have a WCF service project configured as a virtual directory. My service class is "FileLessActivationTest1.Service1" where "FileLessActivationTest1" in the namespace. Open the web.config and enter the following.
Basically it says that if there is a request made for Service1.svc, use Service1 class. Basically that's what svc file did previously. Now you can delete .svc file and check out. Remember, service1.cs is still required.
Hold on, that wasnt the only thing .svc file achieved. It also had the option to specify a service host.
Lets define our custom service host as follows
Now amend the service activation in the config as shown below.
Just like in .svc file, this has an attribute called factory and all we have to do is to supply the factory class name. Thats it. We have a WCF service with file less activation and with custom service host.
The sample is here
Subscribe to:
Post Comments (Atom)



真正的友誼,有如健康失去時,始知其價值..................................................
ReplyDelete弱者困於環境,智者利用環境~~加油! ....................................................
ReplyDelete^^~~輕輕鬆鬆的逛部落格,多謝有您的分享哦~~~........................................
ReplyDelete認清問題就等於已經解決了一半的問題。.............................................
ReplyDelete人類最大的悲劇不是死亡,而是沒有掌握有意義的人生........................................
ReplyDelete待人要誠心,做事要用心,勝負平常心。......................................................
ReplyDelete新的一天 祝你有所成長~~ ....................................................
ReplyDelete成功可招引朋友,挫敗可考驗朋友 ............................................................
ReplyDelete能猜得出女人真實年齡的男人也許耳聰目明,但肯定毫無大腦。哈哈!...............................................................
ReplyDelete一棵樹除非在春天開了花,否則難望在秋天結果。....................................................................
ReplyDelete死亡是悲哀的,但活得不快樂更悲哀。......................................................................
ReplyDelete成熟,就是有能力適應生活中的模糊。.................................................................
ReplyDelete人有兩眼一舌,是為了觀察倍於說話的緣故。............................................................
ReplyDeleteIt takes all kinds to make a world.............................................................
ReplyDeleteQuality is better than quantity.............................................................
ReplyDelete在你一無所有的時候 是誰在陪伴你 他便是你最重要的人............................................................
ReplyDeleteSome people cannot see the wood for the trees.............................................................
ReplyDelete你不能左右天氣,但你可以改變心情.................................................................
ReplyDelete成熟,就是有能力適應生活中的模糊。........... ......... .......... ........... ......... ..........
ReplyDelete喜歡看大家的文章,祝你順心~^^ ..................................................................
ReplyDelete及時行樂-快樂不需要理由..................................................................
ReplyDelete你不能改變容貌~~但你可以展現笑容.................................................................
ReplyDelete良好的開端,已是成功的一半。..................................................
ReplyDelete活是一種鍛鍊靈魂的東西..................................................................
ReplyDelete期待你每一篇文章............................................................
ReplyDelete多謝美味的心靈雞湯......................................................
ReplyDelete很用心的部落格 路過留言支持 ................................................
ReplyDelete來看看你囉~blog很棒! ............................................................
ReplyDelete睇完之後覺得有d頓悟..感謝大大分享..˙ 3˙............................................................
ReplyDelete