Microsoft WebMatrix – to manage Azure Web App
In this blog I would focus on a small mistake that can take a lot of time for us to debug and also will discuss about Microsoft’s WebMatrix tool.
Scenario : Implementing a functionality of uploading a file in our application existing application and writing the data to a table.
- Open the application in visual studio.
- Create “UserUploads” folder in the project which will contain uploaded files
- Write the required peice of code, to upload a file and append the data to a table, in one of the controller (for mvc application).
- Run the program to check, it works for me since I can see the file data in required table.
- Now build and publish the functionality to live website.
- Check the functionality if it works in live website. For me it is not working.
- file is not uploaded or
- file is uploaded but data is not written to the table
I was really confused as in what could be the possible reason behind this failure. The challenge here was, now how should I debug and find the possible error, since same peice of code was working fine in the local environment.
How to debug your app in above scenario?
To manage Azure web apps Microsoft has created an application called “Microsoft WebMatrix”. WebMatrix has a simple interface, once you sign-in into the WebMatrix using your Azure credentials it will give you options, to create new application or to open the existing application from your Azure subscription. In the following steps we will check if file is uploded or not.
- Click on Open.
- Click on Windows Azure, It will display all your sites created under your subscription.
- Select your web app and click on Ok.
- In left panel we can see all the folders related to our application.
- Search for “UserUploads” folder, but folder is not there
So what I understood from this was, my “UserUploads” folder was not created in the live web app when I published my website.
Now the question arises why so?
So now we will look into visual studio if the uploaded file is present or not? To me file is not visible. In solution explorer there is a option called “Show All Files”, I clicked on that and then I was able to see the uploaded file in “UserUploads”. This file is hidden for some reason. When I right clicked on the uploaded file, I got the option “Include in Project” and clicked on it, now the file was visible even when I disabled the “Show All Files” option.
Answer to the second issue is since the folder was empty it did not get created in the live web app.
What to do now?
Now I have 2 options to get my issue resolved:
- publish the webapp again
- create a folder “UserUploads” using WebMatrix
I will choose 2nd option and run the application to check the functionality. Now it works seemlessly.
In this blog we learned about a new tool WebMatrix and a possible way to debug things.
This is a professional weblog, and we have invited experts to share their thoughts, expertise , perspectives and knowledge. The opinions expressed here are purely representing their personal views and not those of any institution, employer or company.