Pass Dnn username to another asp.net application
Last Post 02/08/2014 11:38 PM by meenu. 4 Replies.
Author Messages
meenu
Nuke Master
Nuke Master
Posts:203


--
04/17/2013 1:43 AM  
Advance thanks to all.

I used below link help for creating the webservice for passing username to another sites

http://dnnsilverlight.adefwebserver...fault.aspx



I created 2 webprojects

1. c:/dnn www.test.com (DNN site)

2. c:/redp www.test.com/redp (ASP.NETsite)

I created a asmx webservice in DNN desktop module named "WebServiceDNN" for passing dnn username to the second project.

I added dnn assmx service WebServiceDNN in the project www.test.com/redp

Now my problem is ,after I logged in the dnn site also,username is getting emplty in second site?

Whether the way of calling the webservice in second project is wrong or not?When I tried this webservice with my third project,which is silverlight application then the username is getting correctly without any issues



ASMX function in DNN


_
Public Function GetUsername() As String
Dim strUsername As String = ""
' Get the current user
Dim objUserInfo As UserInfo = UserController.GetCurrentUserInfo()

' If the user is not -1 they are logged in
If objUserInfo.UserID > -1 Then
strUsername = objUserInfo.Username
End If
Return strUsername
End Function




calling webservice from ASP.net project

Dim CallWebService As New WebServiceDNN.WebServiceDNNSoapClient()
Dim sGetValue As String = CallWebService.GetUsername
TxtUserName.Text = Trim(sGetValue)
If TxtUserName.Text = "" Then
'Redirect()
Exit Sub
End If


Joseph Craig
DNN MVP
Posts:11667


--
04/17/2013 6:30 AM  
There is a new "Web Services Framework" that is built into DotNetNuke -- starting in V6 but greatly improved in Version 7.

I would recommend that you Google for "DotNetNuke Web Services Framework" and you will quickly turn up blog posts and Wiki pages that should help you in this regard.

If you look at material written for 6.x, be aware that there may be some differences in the 7.x implementation.

Michael Washington's iWeb module is a bit dated.

Joe Craig, Patapsco Research Group
Complete DNN Support
meenu
Nuke Master
Nuke Master
Posts:203


--
02/02/2014 2:15 AM  
I tried many ways and not success...
I got answer from one forum like below
" dnn webservice will work with silverlight applications only.It is ajax based "

Is it correct?I want to use dnn username to another web module..>Any otherway I can do?
Joseph Craig
DNN MVP
Posts:11667


--
02/02/2014 10:23 AM  
If you are trying to send something TO the second application, it must implement the web service. You DNN application should talk to it.

Joe Craig, Patapsco Research Group
Complete DNN Support
meenu
Nuke Master
Nuke Master
Posts:203


--
02/08/2014 11:38 PM  
Same Problem I discussed here
http://forums.asp.net/t/1899534.asp...pplication
see the last reply In that...What security I should add here?


And I tried one more way....as below...I Added below line in DNN web.config file
compilation debug="true

Now I am getting error like below
The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: 'http://www.w3.org/TR/xhtml1/DTD/xht...strict.dtd">


I dont know where is the problem...My DNN webservice is in Desktop module and the code below

<%@ WebService Language="VB" Class="WebServiceDNNUser" %>

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports DotNetNuke.Entities.Users

http://www.site.com/")> _
_
Public Class WebServiceDNNUser
Inherits System.Web.Services.WebService

#Region "GetUsername()"
_
Public Function GetUsername() As String
Dim strUsername As String = ""
' Get the current user
Dim objUserInfo As UserInfo = UserController.GetCurrentUserInfo()

' If the user is not -1 they are logged in
If objUserInfo.UserID > -1 Then
strUsername = objUserInfo.Username
End If
Return strUsername
End Function
#End Region

End Class




---