Hosting .NET UserControl in Internet Explorer

Hello experts

I'm having a problem in hosting a .NET control within Internet Explorer.  I've followed numerous samples to the letter, and even downloaded example code.  I always seem to be hitting the same problem in that, where the .NET control should be, there is an image placeholder in its place.

I had previously had a text-box in it's place but, resolved that by changing the execution permissions to "Scripts Only" within IIS, as opposed to "Scripts and Executables".

The server where the page & control is hosted IS in the trusted sites, and I've tried it on a remote IIS server on the LAN, as well as running it from the local machine.  I've tried hosting the control in IIS on Windows XP, Windows 2000, as well as using IE6 from Windows 2000 / XP as a client.  All combinations give the same result.

Any advice as to what I'm doing wrong would be greatly appreciated.

Kind Regards

Daryl
LVL 3
hairymingaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mppetersCommented:
I'm a little confused here. You don't really host a .NET user control. A user control (.ascx) is a custom control and can be used to plug a common set of elements in to a page. You use it almost the exact same way as you'd use a textbox, but since it's custom, it needs to be registered at the top of the page in the page directives.

What does the user control do? Can you post it here and how you're using it?

In theory, you could create a user control that just displays an image. So it's hard to diagnose what the problem is without more information.
0
hairymingaAuthor Commented:
Ah, sorry for the confusion.  I was meaning a WinForms control, not an ASP.NET user control.  It's similar functionality to ActiveX that I'm looking for.

I've created a WinNT service that connects to an ACD server in our call center (which doesn't normally offer very good realtime stats) and used the events raised from the server to create a true realtime statistics service.  I have client applications that are written in VB.NET that connect to the service and subscribe to these realitime statistics.  I'm hoping to get the same functionality from within a web page, so that I can have an ASP.NET information service that projects various details onto a collection of plasma screens around the building.

I've achieved something similar to this using an elaborate solution with an extra service on the IIS server, and AJAX but, I'd much rather code a WinForms control that will offer the statistics in realtime, and avoid having to introduce extra services, thereby creating extra points where the whole process can fall over.
0
hairymingaAuthor Commented:
And, to give you an idea of what I've attempted:

Within VS.NET (although I'm actually using #Develop), create a new User Control project in VB.NET, calling the project "HelloWorldControl" with one user control, called HelloWorldCtl

Here's the code for HelloWorldCtl:

Public Class HelloWorldCtl
      Inherits System.Windows.Forms.UserControl
      
      Public Sub New()
            ' The Me.InitializeComponent call is required for Windows Forms designer support.
            Me.InitializeComponent()
            
            '
            ' TODO : Add constructor code after InitializeComponents
            '
      End Sub
      
      Sub CmdClickClick(ByVal sender As Object, ByVal e As EventArgs)
            lblMessage.Text = "Hello, World"
      End Sub
      
      #Region " Designer Generated Code "
      
      Private components As System.ComponentModel.IContainer

      Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                  If components IsNot Nothing Then
                        components.Dispose()
                  End If
            End If
            MyBase.Dispose(disposing)
      End Sub
      
      Private Sub InitializeComponent()
            Me.lblMessage = New System.Windows.Forms.Label
            Me.cmdClick = New System.Windows.Forms.Button
            Me.SuspendLayout
            '
            'lblMessage
            '
            Me.lblMessage.Location = New System.Drawing.Point(8, 8)
            Me.lblMessage.Name = "lblMessage"
            Me.lblMessage.Size = New System.Drawing.Size(224, 23)
            Me.lblMessage.TabIndex = 0
            Me.lblMessage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
            '
            'cmdClick
            '
            Me.cmdClick.Location = New System.Drawing.Point(8, 32)
            Me.cmdClick.Name = "cmdClick"
            Me.cmdClick.Size = New System.Drawing.Size(224, 23)
            Me.cmdClick.TabIndex = 1
            Me.cmdClick.Text = "Click Me"
            Me.cmdClick.UseVisualStyleBackColor = true
            AddHandler Me.cmdClick.Click, AddressOf Me.CmdClickClick
            '
            'HelloWorldCtl
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.Controls.Add(Me.cmdClick)
            Me.Controls.Add(Me.lblMessage)
            Me.Name = "HelloWorldCtl"
            Me.Size = New System.Drawing.Size(242, 65)
            Me.ResumeLayout(false)
      End Sub
      Private cmdClick As System.Windows.Forms.Button
      Private lblMessage As System.Windows.Forms.Label

      #End Region

End Class

The code compiles fine, and works when used in a .NET WinForms application.  Clicking the button places the text "Hello, World" into the label as expected.

I've created a virtual directory in an IIS 5.0 & IIS 6.0 server, called "HelloWorldControlHost" and, set the execution permissions to "Scripts Only" (as advised in various tutorials).  I've placed the resultant DLL from the above code (HelloWorldControl.dll) into the directory that holds the virtual path "HelloWorldControlHost", as well as placed "hello.html" (with the HTML code below).  When browsing the server with http://<server address>/HelloWorldControlHost.html i get the correct page, with no control.  Instead there's a placeholder there like as though Internet Explorer was trying to load an image file (jpg, gif etc).  If I change the execute permissions to "Scripts and Executables" then the same page gives me a textbox instead of the control, as warned in the tutorials.

Not sure if there's something I've misconfigured but, as stated, I've followed numerous tutorials to the letter, with no joy!

HTML Code from hello.html:

<html>
<body>
<p>Hello World Control<br> <br>
<object id="HelloWorldControl1" classid="http:HelloWorldControl.dll#HelloWorldControl.HelloWorldCtl" height="500" width="500" VIEWASTEXT>
</object>
</body>
</html>
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

bobbyrellisCommented:
I see that you've read through many tutorials... but I don't see anything stating that you've setup a .NET code access group policy..

You need to set these security settings so IE knows where it can execute .NET code from a remote location safely..

Check this out..
http://msdn.microsoft.com/msdnmag/issues/02/06/rich/

Try this..
Go to the .NET configurations wizard  (Should be in administrative tools)
expand My Computer/Runtime Security Policy/Machine/Code Groups/All_Code. Right click/New and create a new Code Group with the following properties:
Name: HelloWorldControl
Condition Type: URL
URL= http://localhost/*
Permission set: FullTrust

This should give you permission to use your control.  Please let me know if you've tried anything similar to this.

Hope it helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zephyr_hex (Megan)DeveloperCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:
"Accept bobbyrellis's comment as answer."

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

zephyr_hex Experts Exchange Cleanup Volunteer
0
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.