Click here to Skip to main content
15,884,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, I have a job to do for a company that I have users and tickets management and stood in a part and can not progress, so I decided to come ask for your help. What I want is to log in and users of unregistered shares in C # and all the parts of administration and supervision in ASP.net, the problem is that I do not know how can i make the connection between C # and ASP.net, indeed I do not know if it is possible to do so. What I ask is that if you can tell me and teach me some clue how to get to that I want, I have no code about it, i tried but i didnt reach the goal, but the idea is explained above.
ty in advance
Posted
Comments
perilbrain 3-Jul-12 5:58am    
wasn't this link http://asp.net-tutorials.com/basics/code-behind/ a thing of your concern ???
Zoltán Zörgő 3-Jul-12 5:59am    
As ASP.NET is a web framework + platform over .NET CLR, C# is a .NET language and you can do ASP.NET in C#.
What is the exact problem?
Zoltán Zörgő 3-Jul-12 6:08am    
You want to interact with an asp.net web forms application from a windows forms application?
Paulo Jorge Arteiro Soares 3-Jul-12 6:37am    
yes i want to interact 2 projects one in c# and another in asp.net
Sergey Alexandrovich Kryukov 3-Jul-12 15:35pm    
Makes no sense as formulated. Perhaps you should start from you ultimate goals, not focusing on your idea how to achieve it.
--SA

What i understood from the question is that you want to know whether it is possible to use ASP.NET and some existing C# code in unison.

ASP.NET websites actually use C# as the programming language(VB is also a choice)

ASP.NET does the scripting part which will will be translated to the respective HTML by the framework. the actual business logic is mostly written in C#.

So you can wrap your existing C# code in some logical classes that makes sense as per the application domain and perhaps put it inside a class library. You can use this class library from a ASP.NET website just by adding reference to it.

I hope my understanding of the question is correct. If not please let me know and I will try to refine the answer.
 
Share this answer
 
Comments
Paulo Jorge Arteiro Soares 3-Jul-12 6:20am    
i'll try to give more detailed information with an example:
i have a login (made in c#) and another form to change password when i get in the application for the first time (also in c#)
then if the user is correct, there is a profile validation, so if its a normal user (with basic functions) it appears another form (in c#) when is an administrator, it appears a page in asp.net so my doubt is how to connect c# to asp.net, do i have to put an hiperlink?
Rahul Rajat Singh 3-Jul-12 6:23am    
the forms that you are talking about. are they WINFORMS. because it seems whenever you are using word made in C#, you are actually trying to say a winform page. Am I right?
Paulo Jorge Arteiro Soares 3-Jul-12 6:38am    
the forms that im talking about are windows form, it can be done in wpf too but windows form are good for what is needed
Paulo Jorge Arteiro Soares 3-Jul-12 6:23am    
and another thing i did the asp.net pages in another project, is it wrong? :/ if it was in the same project it wasnt difficult
As ASP.NET is a web framework and platform over .NET CLR, and C# is a .NET language and you can do ASP.NET in C#, you better say web application and windows application, because you might confuse one. According to your clarification, you want to control (kind of) a web application from a windows application.
A) The best way would be to publish web services or wcf services and consume them from the windows applications.
If you can't add this feature, you can exchange data between the two applications in following ways:
B1) Automate a browser (Internet Explorer) via COM - you will have to code interfaces
B2) Use WebBrowser control - but you have to code browser functions
C) Use HttpClient class - there is noting visible, you have to simulate the browser actions and the logic of the client side code
D) Some other IPC - even more to code
 
Share this answer
 
v2
Comments
Paulo Jorge Arteiro Soares 3-Jul-12 8:31am    
ty very much for your help, it helped me understand and im stating to search more about WCF
ty :)
Separate answer to avoid clutter:

To open a ASP.NET website from a windows application:

1. If the website is already hosted on a public server

C#
ProcessStartInfo sInfo = new ProcessStartInfo("http://something.com/default.aspx");  
Process.Start(sInfo);


2. If it is on the same machine
----a. configure the site inside a vitual directory in IIS ( say mysite )
----b. do this
C#
ProcessStartInfo sInfo = new ProcessStartInfo("http://localhost/mysite/default.aspx");  
Process.Start(sInfo);

I hope you will get things to work with this. if not do let me know and I will try to see what i can do.
 
Share this answer
 
Comments
Paulo Jorge Arteiro Soares 5-Jul-12 9:12am    
ty very much i'll try this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900