Archive

Posts Tagged ‘asp.net’

Right Click to Start your Cassini Web Server

October 29th, 2009 ayah No comments

As you all know, cassini (internal web server) which is used by Visual Studio (start from 2005 then 2008), is can be easily activate without starting visual studio.
Below, taken from Phil Haacked website, the configuration for your Windows

32 bit (x86)
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2008 WebServer]
@=”ASP.NET Web Server Here”

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2008 WebServer\command]
@=”C:\\Program Files\\Common Files\\microsoft shared\\DevServer
\\9.0\\Webdev.WebServer.exe /port:8080 /path:\”%1\”"

64 bit (x64)
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2008 WebServer]
@=”ASP.NET Web Server Here”

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2008 WebServer\command]
@=”C:\\Program Files (x86)\\Common Files\\microsoft shared\\DevServer
\\9.0\\Webdev.WebServer.exe /port:8080 /path:\”%1\”"

If your using Visual Studio 2010 beta 2, you can use below configuration

32 bit (x86)
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2010 WebServer]
@=”ASP.NET 4 Web Server Here”

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2010 WebServer\command]
@=”C:\\Program Files\\Common Files\\microsoft shared\\DevServer
\\10.0\\Webdev.WebServer40.exe /port:8081 /path:\”%1\”"

64 bit (x64)
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2010 WebServer]
@=”ASP.NET 4 Web Server Here”

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VS2010 WebServer\command]
@=”C:\\Program Files (x86)\\Common Files\\microsoft shared\\DevServer
\\10.0\\Webdev.WebServer40.exe /port:8081 /path:\”%1\”"

Categories: asp.net Tags: , ,

Debugging Lambdas

March 21st, 2009 ayah No comments

Susah juga ngedebug untuk method kali ini, karena secara default, Visual Studio 2008 / 2008 SP 1 belum bisa ngedebug Lambda expression di window watch. Kalau kita coba masukan expression tersebut ke window watch, nanti ada tulisan

Expression cannot contain lambda expression

Menyebalkan banget ya kalau seperti ini, bisa menghambat kecepatan untuk debug bila ada masalah.
Tapi, hal ini bisa kita atasi dengan cara menginstall sebuah plugins. Cara installnya juga gampang, copy ke

…\Documents\Visual Studio 2008\Visualizers

Kalau pake windows XP copy ke

…\My Documents\Visual Studio 2008\Visualizers

Kalau binun silahkan cek lokasinya ke Tools | Options | Projects and Solutions | General

Hasil yang diharapkan adalah seperti ini
Preview 1
Preview 1
Preview 2
Preview 2
Preview 3
Preview 3

Referensi
1. Ling Farm
2. Expression Tree basics

User Control dan Parent ViewState

March 20th, 2009 ayah No comments

Tadi kebetulan ketemu kasus. Jadi gini, ada aplikasi ASP.NET 2.0 dimana loading contentnya semua diambil secara dinamis. Contentnya sendiri di load dengan cara memasukan string ke ViewState. Hmm…agak unik sih karena biasanya gw kalo mo naro referensi content selalu mengacu ke querystring :D biar gak ribet.

Ini contoh Event Page_Load yang ada di Default.aspx Page sebagai master container

public void Page_Load(obj sender,EventArgs e){
  /** check apakah referensi control sudah ada di Viewstate **/
  if (ViewState["Control"] != null){
     MainContent.Controls.Clear(); /** Hilangin semua control dulu **/
     /** add to maincontent **/
     MainContent.Controls.Add(LoadControl(ViewState["Control"].ToString()));   }
}

Nah sekarang ada pertanyaan.

Gimana caranya untuk mengakses viewstate yang ada di Parent Page melalui UserControl ?

Jawabannya….binun juga. Karena gw dah terbiasa untuk memasukan referensi ke QueryString daripada ViewState. Tapi…..om Google punya beberapa jawabannya

1. Dengan cara membuat public properties di Parent Page, dengan cara itu, properties dapat diakses dengan mudah dari setiap childnya

  public string LoadedControl{get{return ViewState["Control"].ToString();}}

Dari User Control, cara penggunaan menjadi

  public void Test(){
     string control = ((ParentPageType)Page).NameOfProperties;
     MainControl.Controls.Add(LoadControl(control));
  }

Tapi ….. Tapi lagi….Tapi Lagi…..CMIIW, ini hanya berlaku kalau project yang digunakan adalah Web Application Project bukan Website Project. Karena pada Web Application Project, semua sudah menjadi Typed Safe dan dapat dicast. Kalau di website hal ini bisa saja dikerjakan tapi perlu effort lebih (next time ya kita bahasnya)

2. Kalo yang ini lebih gampang, masukin aja ke MasterPage, tentukan ContentPage nya, masukin Page yang mau pake, definisikan ContentPlaceHoldernya….Selesai deh. Lebih lengkapnya cek MasterPage

Good Luck

Categories: Programming Tags: , ,

Finally released ASP.NET MVC

March 19th, 2009 ayah No comments

Akhirnya asp.net mvc keluar!!! cihuyyy…penantian lama setelah pertama kali keluar sebagai CTP pada tanggal 10 Desember 2007, dan kemarin tanggal 17 Maret 2009 released sebagai versi final 1.0. Silahkan unduh ke download link

Gambaran sekilas mengenai ASP.NET MVC (diambil dari Wikipedia)

The ASP.NET MVC Framework is a Model-view-controller framework which Microsoft is adding to ASP.NET.
It allows software developers to build a Web application as a composition of three roles: Model, View and Controller. A Model represents the state of a particular aspect of the application. Frequently, a model maps to a database table with the entries in the table representing the state of the table.
A Controller handles interactions and updates the model to reflect a change in state of the application. A View extracts necessary information from a model and renders a user interface to display that.[1]

The ASP.NET MVC Framework couples the models, views, and controllers using interface-based contracts, thereby allowing each component to be easily tested independently.
By default, the view engine in the MVC framework uses regular .aspx pages to design the layout of the user interface pages onto which the data is composed.
However, different View Engines can be used (for example, you can create a View Engine based on XSLT files).[2]
Additionally, rather than the default ASP.NET postback model, any interactions are routed to the controllers using the ASP.NET 3.5 SP1 Routing mechanism. Views can be mapped to REST-friendly URLs.[1]

Bagi yang belom pernah make ASP.NET MVC, silahkan cek ke Tutorial.
Ini beberapa link tentang perbedaan ASP.NET MVC vs WebForm

Categories: Programming Tags: , , ,