Issue while using WinForm user Control in asp.net MVC applicaton - asp.net

I need to use a WinForm User Control in an ASP.Net MVC4 application.
The control has been embedded using the object tag and classid attribute, but upon viewing the view in browser, only a blank frame is visible, without any cross-sign on top-left corner of frame. The viewing browser is on a machine with .Net Framework 4.5. Similar issue was faced in an ASP.Net application but same was rectified using Registry setting (EnableIEHosting = 1).
Kindly suggest.
Thanks.
Gitika

WinForms user controls are not intended to be used from an ASP.NET (MVC or not) application.
As you should already knows, ASP.NET generate HTML codes that will be sent to the browser when requested. The browser can run on a multitude of operating systems (OS). WinForms user controls essentially only run Under Microsoft Windows.
The second thing to know is that a browser run in a restricted environment and as such as a very limited access to the computer and its OS.
Since you are using ASP.NET MVC, then you should create a partial view that is similar to your user control if this is what you want. Also, another thing to know is that any logic behing your control need to be converted to JavaScript or jQuery. This is what browsers understand.

Related

How to embed 3rd party DLL on the client side of ASP.NET Forms application

I am sorry for very lengthy introduction here but I want to explain my problem in details.
We have a 3rd party dll from one of our vendors that provides Silverlight-based user interface to their data.
We already use that dll in two different projects:
IE toolbar button that opens a UI window to that 3rd party data related to the currently displayed data on the webpage (another web application).
Windows application (.exe) that is called from another windows application when user pressed a particular key combintion (again passing parameters from that application).
We also have a working ASP.NET (forms) intranet application (in-house developed). Users of that application also want an easy access provided by that DLL. I need a solution for making it possible.
As we have corporate controlled environment we have .NET Framework, Silverlight, the toolbar and executable installed on users' machines and all web applications run in IE.
So far I was able to call the existing exe (that I mentioned in #2) and pass the parameters from my asp.net application as ActiveX (similar to what described here How to launch an EXE from Web page (asp.net)). It works but every time it gives that standard popup "An ActiveX control on this page might be unsafe...".
I also tried to create my own dll that wraps the 3rd party dll and embed it in my asp.net page using <object> html tag. It works too but also displays the same popup every time.
Here are my choices (in preference order):
Embed the UI provided by the 3rd party dll (possible wrapped in another dll) in existing page of my asp.net application (currently it opens a new window).
Call executable with parameters (as I do it now) but without annoying pop-up about ActiveX security.
Embed dll using <object> tag as a rich client side custom control.
Either way I don't want users to see the popup every time they go to the 3rd party application.
Is there any way to do it?
If object tag code ran effortlessly without participation from the user it would be a virus/malware delivery mechanism.
One way is to sign the activex object and then get all your machines to trust it, e.g.
Sign an ActiveX control for intranet usage?

ASP.Net Controls in Delphi

I'm sure this question has been asked already but I couldn't find any posts.
Is it possible to use an ASP.net control in Delphi 2006 for Win32? We have some Dev Express ASP.Net visual controls (Chart controls to be exact) that we would like to use in our Delphi application.
Is this possible and how could it be done, preferably without the need to purchase more third party components.
Thank you.
you cannot use this kind of controls directly in a Delphi Win32 Application, because this components are designed to run in a web server with ASP and expose the results to a browser client, i think which your best option is use a local (or remote) web server and make a web page which accepts HTTP requests, and then in TWebBrowser in your Delphi Win32 app load the page to get results.
That is not going to be possible as the DevExpress ASP.NET controls are wired up via handlers in the web.config and not something that can be forced into Delphi. I assume you have looked at DevExpress's VCL controls for (Delphi and C++ Builder Controls) on it's website? If the VCL product suite does not have what you need then you will need to look elsewhere.

Windows Forms message box doesn't work in published ASP.Net application

We're developing .Net Application using asp.net and C# and .Net Framework 3.5.
We are using windows form message box in a .Net application.
This windows form works great on the debug mode but once we publish the application this message box won’t work.
We are referencing System.Windows.Form.dll in order to use the message box features.
Kindly advice if we need to register this DLL or follow some configuration steps in order to solve this problem.
Thank in advanced,
Jad
Don't use MessageBox in a web application. It will show up on the server console, there's nobody around to click the OK button. I assume that ASP.NET has some counter-measures against it, given that it is such a serious denial-of-service attack.
If you are using unreferenced classes a project/solution is usually not even compiled.
So probably the problem is in another place. Are you sure that the code that should display the MessageBox is executed?
EDIT: When you develop web applications (ASP.NET), as described by you in comments, you cannot use Winforms MessageBox.
Try showing it with javascript, if you really need it
Response.Write("<script>alert('This a message')</script>");

Embed ASP.NET application in VB6

Does anybody have a clue how I might embed an ASP.NET 3.5 app inside a Visual Basic 6 application?
My other option is to provide a hyperlink inside the VB6 application that will open the ASP.NET app.....BUT I would prefer to embed the ASP.NET app within a tab control in VB6 if at all possible.
thanks in advance
For the auto-login to the .net app (assuming it's ASP.net) I would have the vb6 application login process write a session GUID to the database, and use it as a get or post variable when building a link to the .net application.
On the ASP.NET side, modify your MembershipProvider to honor a guid and username as evidence of successful authentication to the vb6 app.
There may be some additional security precautions you should take depending on how guarded your environment needs to be.
Realistically, your best option is probably to use the Web Browser control on a new tab, and point that at your ASP.NET application.
For auto-login, you SHOULD be able to have users login once. You'll probably need to enable a "remember me" feature in your ASP.NET application.
It'd be a two part process.
Create a .NET library to host asp.net, http://www.west-wind.com/presentations/aspnetruntime/aspnetruntime.asp.
Then use interopt to launch the library. Sounds like a really bad idea though.
That sounds like a terrible idea.
I think you should give more background on the situation so alternatives can be suggested.
EDIT: You say the VB6 app cannot be rewritten... but can it be edited? Depending on the complexity of the functionality in the ASP.Net app you could alter the ASP.Net app to include a web service and access that functionality from the VB6 app.

Sharepoint controls in ASP.NET application

Is there a way I can use the sharepoint controls in a ASP.NET web application like any other controls that come out of box for ASP.NET? If yes, what are the pre-requisites I need to install?
Thank you,
Harsha
Yes, you can use SharePoint "controls" in an ASP.NET application, as long as the application is running in SharePoint.
In other words, the prerequisite is SharePoint.
Most controls have internal dependencies on SharePoint (i.e. they use SPContext or SPWeb internally). Also, since they are contained within the Sharepoint Assemblies, you can not just take the .dlls and put them in your app.
In short: In most cases, it will be better to re-build them using reflector. Which one are you looking at?
What specific controls are you referring to? Those that you find in SharePoint Designer?
If you are referring to Web Parts in WSS v3, those that are using the ASP.NET Web Part as the base web part (the recommended approach) may work fine in ASP.NET since the Web Part class inherits from Panel which inherits from Web Control (going from memory here) - all ASP.Net classes. It would just depend on whether the web part has any SharePoint specific code which is highly dependent upon the web part.
Host the application in SharePoint's _layouts directory (see this video for more details). Your ASP.NET app will then be "running in SharePoint" and have access to all SharePoint controls.
Note that some controls don't work unless they are running on an actual SharePoint page.

Resources