?
Solved

Hosting .NET UserControl in Internet Explorer

Posted on 2007-03-28
6
Medium Priority
?
1,132 Views
Last Modified: 2013-11-07
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
0
Comment
Question by:hairyminga
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Expert Comment

by:mppeters
ID: 18807438
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
 
LVL 3

Author Comment

by:hairyminga
ID: 18808109
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
 
LVL 3

Author Comment

by:hairyminga
ID: 18808362
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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 1

Accepted Solution

by:
bobbyrellis earned 2000 total points
ID: 18996051
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
 
LVL 44

Expert Comment

by:zephyr_hex (Megan)
ID: 21073645
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
 
LVL 1

Expert Comment

by:Computer101
ID: 21101997
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question