About a year ago I had the opportunity to write an article for 4GuysFromRolla: Hosting a Windows Control in a Web Form. The article is very straight-forward. It also gets a lot of questions.
The main point is that you can host a Windows UserControl within a web page. There are some highlights from the article, and from what I've learned since then:
- This requires that the client has the .Net Redistributable installed.
- Passing data to and from the WinConrol is hard. You can pass data to the control by dynamically recreating the HTML for it (discussed in the article). The best way I know to get data from the control is via an Xml Web Service (not by writing to an Xml File, as I indicated in the article). Writing to a file system could be a security leak, and requires tweaking the security configuration.
- While the WinControl appears different when embedded in the web page, it can open up a fully-functional win pop-up form. For example, you could add a Timer to the popup form, but it may not work in the WebForm.
The most common problems I get from readers trying to get their WinControl to work:
- They haven't run the demo, and there's some issue that would be flushed out if they had.
- It works on their Dev machine, but not someone else's - usually because the other person's machine didn't have the .Net Redistributable installed.
- They're trying to access some secure resource - if possible I try to avoid this and use web services instead.
I think embedded WinControls are great for toys - for example you want to make a simple online educational game for a school. However, I find that their security and deployment restrictions are cumbersome for an enterprise app.
No comments:
Post a Comment