Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 12th, 2006, 02:16 PM
Authorized User
 
Join Date: Aug 2006
Location: delhi, delhi, India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to KamalRaturi Send a message via Yahoo to KamalRaturi
Default conversion of vb to C# code

hi frnds,
I have to convert this line of code to C# equiv.

 if (HttpContext.Current.User.Identity is FormsIdentity)
     {
        FormsIdentity id =
            (FormsIdentity)HttpContext.Current.User.Identity;
        FormsAuthenticationTicket ticket = id.Ticket;

        // Get the stored user-data, in this case, our roles
        string userData = ticket.UserData;
        string[] roles = userData.Split(',');
        HttpContext.Current.User = new GenericPrincipal(id, roles);
     }


I have done import System.Security.Principal namespace .But Line
-----------------------------------------------------
FormsIdentity id =(FormsIdentity)HttpContext.Current.User.Identity;

-------------------------------------------------------
Gives error.this code is being used in Global.asax


Thanks in advance!
 
Old September 12th, 2006, 03:31 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

What is the error?

"The one language all programmers understand is profanity."
 
Old September 12th, 2006, 04:04 PM
Authorized User
 
Join Date: Aug 2006
Location: delhi, delhi, India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to KamalRaturi Send a message via Yahoo to KamalRaturi
Default

hi,
i have mistaken the word C# in place of VB (First Line of my New post)

I have to convert this line of code to VB equiv.

Thanks!
 
Old September 12th, 2006, 04:08 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This should work.

Dim id as FormsIdentity = CType(HttpContext.Current.User.Identity, FormsIdentity)

"The one language all programmers understand is profanity."
 
Old September 12th, 2006, 04:34 PM
Authorized User
 
Join Date: Aug 2006
Location: delhi, delhi, India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to KamalRaturi Send a message via Yahoo to KamalRaturi
Default

Thanks for replying Sir,
Just tell me one more line equiv of VB
----------------------------
 if (HttpContext.Current.User.Identity is FormsIdentity)
-----------------------------

it is also showing error.

-----------
Waiting (I think u r Online)
-------------
 
Old September 12th, 2006, 04:51 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

If TypeOf FormsIdenity Is HttpContext.Current.User.Identity then

end if

"The one language all programmers understand is profanity."
 
Old September 13th, 2006, 04:35 AM
Authorized User
 
Join Date: Jul 2005
Location: Pune, Maharasthra, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try out this code conversion utility for .NET. Though it converts the code but you need to pay attention to some of its lines

suppose arr(0) = 45. You need to change it to arr[0] by your own. The utility won't do it for you.

http://www.developerfusion.co.uk/Utilities/





Similar Threads
Thread Thread Starter Forum Replies Last Post
File Conversion in VB.net? yuvin Visual Studio 2005 1 February 5th, 2007 03:36 PM
Help w/conversion from C# to VB.NET kwilliams VB.NET 9 October 16th, 2006 12:06 PM
Code conversion and proper attribution qnr BOOK Beginning Linux Programming, 3rd Edition 1 April 5th, 2006 12:48 AM
VB to C# conversion shazia1 VS.NET 2002/2003 3 June 29th, 2005 08:12 PM
code conversion tr8it0r Access VBA 1 April 11th, 2005 08:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.