|
hi Pankaj,
you can easily do that.
public DirectoryEntries GetVirtualDirectories()
{
try
{
string serverName = "localhost";
string VirDirSchemaName = "IIsWebVirtualDir";
iisServer = new DirectoryEntry("IIS://" + serverName + "/W3SVC/1");
DirectoryEntry folderRoot = iisServer.Children.Find("Root", VirDirSchemaName);
return folderRoot.Children;
}
For Load it into a Combo box
private void load_VirtualDir()
{
DirectoryEntries entries = GetVirtualDirectories();
foreach (DirectoryEntry d in entries)
{
cmboVirtual.Items.Add(d.Name);
}
}
Happy Coding
|
|
|
|
|
hi Abhijit,
What is iisserver here?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
private DirectoryEntry iisServer;
|
|
|
|
|
Is there any way to further explore the virtual directories(the files inside the virtual directory)?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Every Virtual Directory should have a physical location. if you know the physical location, try to explore that one,insted of virtual directory.
Thanks
|
|
|
|
|
actually i am trying to access the virtual directory of a remote computer , where no folder is shared.
Can i explore the virual directory now?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
AFAIK, you won't be able to list virtual directories of a remote system.
|
|
|
|
|
Yes. Try using Directory Info class
Sample
DirectoryInfo info = new DirectoryInfo("IIS://localhost/W3SVC/1/ROOT/ReportServer001Test");
FileInfo[] fileinfo = info.GetFiles();
foreach (DirectoryInfo fi in fileinfo)
{
Console.WriteLine("\t" + fi.Name);
}
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
Laddie wrote: DirectoryInfo info = new DirectoryInfo("IIS://localhost/W3SVC/1/ROOT/ReportServer001Test");
Pankaj,
Insted of localhost, you can try to give the IP address of Remote system.
but , i think you should required the Credential for that
|
|
|
|
|
Laddie - This won't work as the path you specified is not correct. I guess it will be an invalid path format for the DirectoryInfo class.
Laddie wrote: foreach (DirectoryInfo fi in fileinfo)
{
Console.WriteLine("\t" + fi.Name);
}
foreach (FileInfo fi in fileinfo)
{
Console.WriteLine("\t" + fi.Name);
}
|
|
|
|
|
You are right.. It is my mistake.
I was playing with both the GetDirectories() and GetFiles() functions and which i copied to reply the code i forgot to change it in the second place.
Thanks for correcting
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
Glad to know it helped. You are welcome
|
|
|
|
|
I am trying to get a single login working across two sub domains
(www.my.domain.com and mySubDomain.my.domain.com)
When I create the authentication cookie in www.my.domain.com, I can read most of the cookie settings, but domain does not seem to get set. I have tried setting the domain in the web.config file and also in the login code. In both cases, I can't read it (from www.my.domain). It returns an empty string.
I can't read the cookie at all from mySubDomain.my.domain.com.
Web config file Forms setting is:
<authentication mode="Forms">
<forms name="AuthCookie">
domain=".my.domain.com"
enableCrossAppRedirects="true"
loginUrl="~/Authenticate/logon.aspx"
protection="All"
timeout="60"
path="/"
/>
</forms></authentication>
Both applications have the same settings.
I also have a machineKey set (identical across both apps).
Any idea of what is wrong?
Cheers.
|
|
|
|
|
Hello everyone,
I have a query that's probably quite common, but there's a part of how Threads are managed that I don't quite fully grasp, so i'm wondering what's the best way to solve my scenario.
The functional overview is quite simple: My site visitor wants to search, he enters a query, I forward that query to a 3rd party catalog that searches for me, and I return the results to the client.
The search works over AJAX, so I'm receiving the request on an ASHX handler, and returning the HTML that the JS will then put into a div directly.
This 3rd party service is expected to take a while to respond (many seconds)
My question is how to handle the threads on the server to avoid a bottleneck.
The obviously simplest way is to have the ASHX open a WebRequest to the 3rd party catalog directly. The obvious problem is, i can only have 25 queries running simultaneously in that case (i'm picking 25 as the number of threads in my pool from now on. I know this can be changed but that's not the point.)
I want to release these threads so they can keep handling other requests while the searches I spawned are pending, so the first thing I'm doing is using an IHttpAsyncHandler
In the method where I call the 3rd party URL, i'm using HttpWebRequest.BeginGetResponse (with a callback), so that part is handled Async too.
My question is...
When I call BeginGetResponse, I can immediately free the thread that I'm in and return it to the pool.
However, when I do that, am I not spawning a new thread that is alive while the request goes on, and ends up calling my callback once it finishes?
If I AM spawing this new thread, doesn't this consume one thread from the pool too, and I'm actually getting a net effect of the same as going synchronous?
If I am NOT spawning a new thread, then how does my callback get called? Who is checking whether this async method I started is finished? (This is the main part of the puzzle that I don't quite grasp)
If a response from the 3rd party catalog takes forever, could I potentially have 1000 of these async WebRequest methods pending a response at the same time, and still be using no threads (or very few) from the 25-thread pool?
Or will I only be able to have 25 of these waiting for a response from the catalog, and the rest will be queued up by IIS?
Below I'm attaching the code that I wrote that shows what i'm doing.
This is obviously oversimplified. I left the "architectural" stuff, and removed all the things specific to my case.
Am I doing things right? Should I be using an Async HTTP Handler, AND calling BeginGetResponse?
Is there a better way?
Thank you very much for your answers!
Daniel
----------------------------------------------------------------------------------------------
<![CDATA[<%@ WebHandler Language="VB" Class="SearchHttpHandler" %>]]>
Option Strict On
Imports System.Threading
Imports System.IO
Imports System.Net
Public Class SearchHttpHandler
Implements IHttpAsyncHandler
Implements IReadOnlySessionState
'---------------------------------------------------------------------------------------
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
End Sub
'---------------------------------------------------------------------------------------
Function BeginProcessRequest(ByVal context As System.Web.HttpContext, ByVal cb As System.AsyncCallback, ByVal extraData As Object) As System.IAsyncResult Implements IHttpAsyncHandler.BeginProcessRequest
context.Response.Write("Started on thread: " & _
Threading.Thread.CurrentThread.ManagedThreadId & " - " & _
Threading.Thread.CurrentThread.IsThreadPoolThread.ToString & "<br />")
'Instantiate the AsyncResult object that'll give us a hold to the context and the callback
Dim theAsyncResult As New SearchAsyncResult(context, cb, extraData)
theAsyncResult.Search()
Return theAsyncResult
End Function
'---------------------------------------------------------------------------------------
Sub EndProcessRequest(ByVal result As System.IAsyncResult) Implements IHttpAsyncHandler.EndProcessRequest
Dim theObj As SearchAsyncResult = DirectCast(result, SearchAsyncResult)
theObj.Context.Response.Write("Ended on thread: " & _
Threading.Thread.CurrentThread.ManagedThreadId & " - " & _
Threading.Thread.CurrentThread.IsThreadPoolThread.ToString)
End Sub
'---------------------------------------------------------------------------------------
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
'======================================================================================
'======================================================================================
Public Class SearchAsyncResult
Implements IAsyncResult
Public Context As HttpContext
Private mASPNETCallback As AsyncCallback
Private mExtraData As Object
Private mIsCompleted As Boolean
Private mAsyncWaitHandle As ManualResetEvent
Private mRequest As HttpWebRequest
Private mQuery As String
'-------------------------------------------------------------
Public Sub New(ByVal context As HttpContext, ByVal ASPNETCallback As AsyncCallback, ByVal ExtraData As Object)
Me.Context = context
mASPNETCallback = ASPNETCallback
mExtraData = ExtraData
End Sub
'-------------------------------------------------------------
Public Sub Search()
If Context.Request.QueryString("q") IsNot Nothing Then
mQuery = Context.Request.QueryString("q")
End If
'Return "No Results" if there is no query
If mQuery = "" Then
Context.Response.Write("No Results")
CompleteRequest()
Exit Sub
End If
'Otherwise, make an async call
Dim URL As String = "xxxxxxx?q=" & mQuery
mRequest = DirectCast(WebRequest.Create(URL), HttpWebRequest)
mRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
mRequest.Method = "GET"
mRequest.BeginGetResponse(AddressOf SearchCallback, Nothing)
End Sub
'-------------------------------------------------------------
Private Sub SearchCallback(ByVal ar As IAsyncResult)
Dim WebResp As WebResponse = mRequest.EndGetResponse(ar)
Dim sReader As New StreamReader(WebResp.GetResponseStream())
Dim result As String = sReader.ReadToEnd()
Context.Response.Write(result)
CompleteRequest()
End Sub
'-------------------------------------------------------------
Private Sub CompleteRequest()
mIsCompleted = True
SyncLock Me
If mAsyncWaitHandle IsNot Nothing Then
mAsyncWaitHandle.Set()
End If
End SyncLock
If mASPNETCallback IsNot Nothing Then
mASPNETCallback(Me)
End If
End Sub
'---------------------------------------------------------------------
#Region "Implementation of IAsyncResult dummy members"
Public ReadOnly Property AsyncState() As Object Implements System.IAsyncResult.AsyncState
Get
Return mExtraData
End Get
End Property
Public ReadOnly Property AsyncWaitHandle() As System.Threading.WaitHandle Implements System.IAsyncResult.AsyncWaitHandle
Get
SyncLock Me
If mAsyncWaitHandle Is Nothing Then
mAsyncWaitHandle = New ManualResetEvent(False)
End If
Return mAsyncWaitHandle
End SyncLock
End Get
End Property
Public ReadOnly Property CompletedSynchronously() As Boolean Implements System.IAsyncResult.CompletedSynchronously
Get
Return False
End Get
End Property
Public ReadOnly Property IsCompleted() As Boolean Implements System.IAsyncResult.IsCompleted
Get
Return mIsCompleted
End Get
End Property
#End Region
'---------------------------------------------------------------------
End Class 'SearchAsyncResult
|
|
|
|
|
Hi,
I've built a FormView with a number of fields and a corresponding insert template. It works fine and I can insert a record with no problem. However, I now want to replace one of the text fields with a dropdownlist so I can select from a number of fixed options. I've supplied a data source which references a small list of values table:
<asp:formview id="fv1" runat="server">
DataSourceID="sdsProducts" DefaultMode="Insert">
<insertitemtemplate>
Name:
<asp:textbox id="txtName" runat="server">
Type:
<asp:dropdownlist id="ddlType" runat="server">
DataSourceID="sdlType" DataTextField="Value" DataValueField="ID" />
<asp:sqldatasource id="sdlType" runat="server">
ConnectionString="<%$ ConnectionStrings:myConnStr %>"
SelectCommand="SELECT * FROM [lovType]">
<asp:sqldatasource id="sdsProducts" runat="server">
ConnectionString="<%$ ConnectionStrings:myConnStr %>"
InsertCommand="INSERT INTO [tblProducts] ([Name], [Type])
VALUES (@Name, @Type)">
<insertparameters>
<asp:parameter name="Name" type="String">
<asp:parameter name="Type" type="String">
I can see the values in the dropdownlist but it doesn't seem to insert any value for the dropdownlist. I'm having no luck with this at all. Is it even possible to place a dropdownlist control in a FormView's InsertItemTemplate?
Thanks for looking
Evil cannot be conquered in the world... It can only be resisted within oneself.
|
|
|
|
|
Dear All,
Does anyone know how to get the number of an HTTP Response bytes sent to some client?
I`ve already done some research but nothing...
Thanks in advance.
Best regards,
Marco Alves.
|
|
|
|
|
Hello all,
In my webservice, in a webmethod named emData, I am extracting some data from a sql server database and arranging those data in a DataSet following some query. Now that DataSet is the return value of my webmethod emData. I am working with C#
How can I show that dataset in my client aspx page in a normal table after receiving it from the webservice?
Please help me to solve this out.
with regards,
Faysal
|
|
|
|
|
What do you mean "normal table"?
The procedure should be the same regardless of whether you are receiving the dataset from webservice or another class. I don't understand what you are asking
|
|
|
|
|
Actually my question was just How can I represent that dataset.
|
|
|
|
|
System.Globalization.PersianCalendar pcal = new System.Globalization.PersianCalendar();
string GreDateTime = pcal.ToDateTime(Convert.ToInt32(stDate[0]), Convert.ToInt32(stDate[1]), Convert.ToInt32(stDate[2]), Convert.ToInt32(stTime[0]), Convert.ToInt32(stTime[1]), 0, 0).ToString();
i write that code and i see the 2005-05-05 in GreDateTime in one computer and see 05-05-2005 in GreDateTime in the other computer wich one of them is right? how can i set that format?
|
|
|
|
|
Instead of testing with 05-05 (5th of may) try checking 12-30 (30th of December). Now you can see if you have any problems.
The way how date time gets printed depends on the Culture, which is set ao. in the Local Settings of the operating system. That explains why the same date looks different on two computers.
Also see http://www.codeproject.com/script/Forums/View.aspx?fid=12076&msg=2564813[^] for the correct way of interpreting datetime strings.
|
|
|
|
|
It probably depends on he language settings of each computer.
You should use the built in DateTime class, and format it as needed.
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd"));
|
|
|
|
|
Hi All.
I need to check the data on screen from a web page and access data to a specific text box. I haven't values like Textbox.Name, TextBox.Value, Lavel.Name or Lavel.Value.
How can I do that.
Thanks a lot.
|
|
|
|
|
I think you need to reword your question so that we can understand what your asking.
Possibly posting a small snippet of code if applicable.
|
|
|
|
|
HI,
I am using update panel in my application.but i am facing one issue.
I have one page for new enrolment of members, and i have two user controls Step1.ascx and Step2.ascx. My functionality is that at a time olny one control is visible on the page and other will be hide. for eg when user fills all fields in step1 and press next button then step2.acsx will be be visible true and user Step1.ascx will be visible false. all this happening at postback.
both control is under update panel to avaid post back during change of visibility.
On Step1.ascx i have one javascript variable var_pageName and its value is "Step1".
I want to update this value during post back to "Step2" when Step2 user control visible is true and vise versa. but the problem i am facing is javascript value is not updating during postback. I had tried this with scriptManager.RegisterClientScriptBlock and also with scriptManager.RegisterStartupScriptBlock by palacing it on both Usercontrol level and also on page level.
Please help as this is ver y urgent.
Sajid A.
|
|
|
|