Categories
Uncategorized

Remote connection to Visual Studio Development Server: The easy Way!

Let me explain the scenario. I am a novice .NET developer. I have picked up the .NET framework a couple of weeks ago. I am well versed in PHP and Python and have worked on the LAMP stack so far. I use Pay monthly websites, cause as a developer I know what’s the best way I could save a ton of money and make more profits. I am relatively new to the Windows and Visual Studio environment. I have tasted many technologies and I love experimenting. Web Application Development being my primary concentration, I decided to give Visual Web Developer a try.

I have Visual Studio 2010 Ultimate installed on a Windows 7 Notebook. I actively develop PHP MySQL apps on the same PC. I am a BTCL ADSL subscriber and have a Belkin N Series router. With my WAMP Server, the apache can listen to my ISP IP address and anyone can visit my local web apps over the internet using that address. That’s pretty cool! Since I am a beginner, I decided not to install IIS and stick to the development server of Visual Web Developer (or VS). For security reasons, the dev server listens only to internal ports and refuses remote connection. Duh! I don’t want to pay for Windows hosting just to show off how fast I am learning!

After browsing the internet for a while, I came across a tool :- SPI Port Forward. It can forward any ports on the machine to any other ports on another host. Pretty cool! Remember, localhost is a host that has an IP address 127.0.0.1. This IP address is internal, that is available only to your machine. So, we can fool VS by forwarding any incoming connection to a port on localhost. VS will think that this is an internal connection. 🙂 Yeah, it’s that easy!

So what do we do? We download the stand alone SPI Port Forward Utility. We map a port on our pc (say, 3500) and map it to the VS dev server port. But, wait! VS uses random ports for running the app. How do we forward the port? That’s easy. Just go to the project properties, go to the “Web” section and define a fixed port under the “Server” section. Cool!

Now, note that, you can not forward port 3500 to 3500. After all its the same machine. So I launch VS on port 8000 and use the port 3500 for accepting incoming connection. By the way, since I am inside another Wireless network, I had to setup the router to forward all ports to my Notebook PC at the first place. That’s it! We’re done.

What happens now? When someone visits your ISP IP address, the request is made to your router. Your router forwards it to port 3500 to your machine. Your machine forwards it to the internal port 127.0.0.1:8000 where the VS Dev server is running!

Now you can show the world off your .NET skills! Have fun 😀

Categories
PHP

Running WAMP Server at Windows Startup

While using Linux, the LAMP stack was always ready to work on. But on Windows, I have to manually start the WAMP server. This is a pain in the ass! 😛

Today I found a way to run WAMP server at startup. I’m going to share how.

# Go to start menu.
# Right click on My Computer
# Click Manage
# In the “Services and Applications” section, find “wampapache” and “wampmysqld”.
# To start these services on Windows Startup, double click on each of them, set startup to Automatic.

Restart your PC to see if it works 🙂

PS: We are only starting the apache and mysql servers on startup. So don’t expect the WAMP icon in the taskbar. Visit localhost to see if the server is online 🙂

Categories
PHP

Zend Framework: Debugging and Loading Custom Ini

Another blog post for self documentation 😉

Debugging:
Create a init() method in the controller. Put the following codes to disable the layout and turn off view rendering. Now, use print_r(), var_dump() or try…catch whatever you like 🙂

Please note: please make sure if you have any layout enabled already, if you don’t have one, trying to disable the layout will obviously go wrong. In that case, uncomment the respective line.

Even without all these hassles, anywhere in your controller you can use Zend_Debug::dump() which works like var_dump(). But it won’t work in case there is an Application Error (a fatal error somewhere). So, try…catch is a better debugging solution when you can’t trace the source of the problem. For a quick debugging, use Zend_Debug::dump().

Loading Custom Ini

Create a ini file in the “application/configs/” directory. Lets name it mydata.ini. Then create a block of data like this:

Now, you can load these configuration anywhere using the following codes:

The second parameter of the Zend_Config_Ini constructor loads a specific block from the ini file.