|
Hi all, if I bind my datatable which contains the path of a file or files in a folder on the web server, to a gridview like the following, I will get a gridview with file paths inside of it.
DataTable myTable = new DataTable("myData");
myTable.Columns.Add("URL", typeof(string));
string[] fileEntries = Directory.GetFiles(Server.MapPath("~/Uploads/"));
int linkL = 0;
foreach (string fileName in fileEntries)
{
myTable.Rows.Add("~/Uploads/" + Path.GetFileName(fileName));
linkL++;
}
myGrid.DataSource = myTable;
myGrid.DataBind();
As it stands, the code snippet above successfully allows users to download a file by clicking on its path inside of the URL Column of the Gridview. So basically if the file from the web folder is Test.txt I would see the following path in the URL column:
"~/Uploads/Test.txt
But what if I want to change the name Test.txt to a different name and still be able to download the fie? I have tried to change Test.txt to something else by inserting a new name in the path but I get an error message saying that the new file is not found. Any suggestions will be greatly appreciated, thanks for your help.
|
|
|
|
|
ASPnoob wrote: I get an error message saying that the new file is not found. Then you need to investigate why the path that you are providing does not match an existing file.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I have created a server control in asp.net that generate dll and we can use it an any another application we need. It is so helpful.
Now I want to create server control type of application in PHP and ASP.NET MVC 3.
Can you provide me some sample application or example for PHP and ASP.NET MVC 3, so that I am able to achieve my task.
Please reply ASAP.
Thanks in Advance.
|
|
|
|
|
I have an ASP.net\AJAX 4.0 forms application that is having a performance issue. The app is hosted on go daddy shared hosting servers. Intermittently (about half the time) a page request hangs for a significant amount of time. I have run lots of tracing on it and found that the hangup is happening before the request even gets to the server. I have setup ASP.net tracing to spit out a timestamp gathered during the application.begin_request event. An example of a typical scenario I am observing is that I request a page at 00 seconds and get the response at 30 seconds. ASP.net tracing tells me that application.begin_request (via the timestamp) started at 27 seconds and the entire page cycle took less than 3 seconds to complete.
I also traced with the Internet Explorer 9 F12 debug feature and if I look at the timings tab (in detail view) I observe that all of the hangup time is occuring in what Internet Explorer is calling the "Start" event - the description is "The time from when the request was initially created to when the request is sent".
So my question is, does anybody know what would cause requests to intermittently get held up in the browser like that? It does not happen in development (only from hosted site) and occurs from multiple types of browsers and multiple PCs - so it is not isolated to a particular browser environment.
|
|
|
|
|
|
Those are good reads as I was not familiar with that but unfortunately to use those would require a lot of code re-writing. I am confident that this latency is not from AJAX. I have run tracing in fiddler, dynaTrace, and IE and in all cases the tools report a responsive site in all ways other that this strange random latency in the pre-request state. I really need to simply identify what is going on during the browser start\wait period on the random page requests that experience latency. However it seems that there is no information about anyone having a similar situation anywhere on the web.
|
|
|
|
|
Hi,
I have WCF ServiceA and WCF ServiceB. ServiceA is calling ServiceB. Both of them are using BasicHttp binding. But I am getting the exception with message as below. When I am trying to call the ServiceA and ServiceB individually from a test page both of them are working fine.
But I want to call ServiceB from ServiceA. I am not using the ServiceReference to call the serviceB I am calling the Service in the following way
Code to create the Service proxy
Imports System.ServiceModel
Imports System.ServiceModel.Web
Imports System.ServiceModel.Description
Public Class ServiceFactory(Of T)
Public Shared Function GetBasicHttpChannelForService(ByVal source As String) As ChannelFactory(Of T)
Dim factory As ChannelFactory
Dim result = String.Empty
Try
'Get the channel from WCF
Dim address As EndpointAddress = New EndpointAddress(source)
Dim binding As BasicHttpBinding = New BasicHttpBinding()
binding.MaxReceivedMessageSize = 2147483647
binding.ReaderQuotas.MaxArrayLength = 2147483647
binding.MaxBufferPoolSize = 2147483647
binding.CloseTimeout = New System.TimeSpan(1, 1, 1)
binding.OpenTimeout = New System.TimeSpan(1, 1, 1)
binding.ReceiveTimeout = New System.TimeSpan(1, 1, 1)
binding.SendTimeout = New System.TimeSpan(1, 1, 1)
If factory Is Nothing Then
factory = New ChannelFactory(Of T)(binding, address)
ElseIf factory.State = CommunicationState.Closed Then
factory = New ChannelFactory(Of T)(binding, address)
ElseIf factory.State = CommunicationState.Faulted Then
factory.Close()
factory = New ChannelFactory(Of T)(binding, address)
ElseIf Not factory.State = CommunicationState.Opened Then
factory.Close()
factory = New ChannelFactory(Of T)(binding, address)
End If
Catch ex As Exception
End Try
Return factory
End Function
Public Shared Sub CloseChannelFactory(ByRef factory As ChannelFactory)
If Not factory Is Nothing Then
If factory.State <> CommunicationState.Closed Then
factory.Close()
End If
factory = Nothing
End If
End Sub
End Class
And in the test page's load even I am creating the Service proxy in the following way
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim factory As ChannelFactory(Of IStayAtWorkService)
'GetMessages(New Guid("b14bc077-f1df-457c-9f7e-7cb9e0bc1cf3"))
'Dim factory As ChannelFactory(Of IStayAtWorkService)
Try
factory = ServiceFactory(Of IStayAtWorkService).GetBasicHttpChannelForService _
(ConfigurationManager.AppSettings("StayAtWorkServiceAddress"))
Dim sawService As IStayAtWorkService = factory.CreateChannel()
Dim inputFileBytes() As Byte
Dim inputFile As String = ConfigurationManager.AppSettings("InputFiles")
Using fstream = New FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
Using br As BinaryReader = New BinaryReader(fstream)
inputFileBytes = br.ReadBytes(fstream.Length)
br.Close()
End Using
fstream.Close()
End Using
Dim fUpload As New RequestFile()
fUpload.FileName = inputFile
fUpload.FromDiv = "Accordian1"
fUpload.ImageBytes = inputFileBytes
fUpload.RequestId = 2
Dim d = sawService.SaveRequestFile(fUpload)
GridView1.DataSource = d
GridView1.DataBind()
Catch ex As Exception
Finally
ServiceFactory(Of IStayAtWorkService).CloseChannelFactory(factory)
End Try
End Sub
Where am I missing, doesnt WCF support calling one service from another service or is it because I am creating service client for serviceB by using runtime mechanism. Please give me some solution. I would be really really thankful. When I am able to call individually why am I not able to call one service from another service. Please help me in fixing it. Following is the error message I am getting.
The remote server returned an unexpected respo
nse: (400) Bad Request.
And Stack TRace is :
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at WA.LNI.StayatWork.Service.IStayAtWorkService.SaveRequestFile(RequestFile fUpload)
at WA.LNI.StayatWork.Public.UI.WebServiceTestPage.Page_Load(Object sender, EventArgs e) in D:\source\SourceCode\StayatWork-VS2010\WA.LNI.StayatWork.Public.UI\WebServiceTestPage.aspx.vb:line 157
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
I have a C# 2010 web application that is having problems displaying a few items from the master pages. Thus I need to be able to determine what the issue. Due to that fact, I have the following questions:
1. F12 Developer Tools look like they can be used to analyze what a problem is. Can you tell me where I can obtain a copy of the F12 Developer Tools? Are the part of Visual Studio.net 2010 professional edition? If so, can you tell me what part of the install I would obtain the F12 developer tool from?
2. If the F12 Developer Tools are not part of visual studio, can you tell me where I can download the tool from?
3. Do you have directions I can follow on how to use this tool?
|
|
|
|
|
I'm confused.
You have the source code to the web application. Right?
Why can't you use VS2010 to debug the application?
|
|
|
|
|
I am having problems with the master page markup. It is not displaying correctlty. I am hoping you can tell me how to see where there are problems with master pages that contain html and css pages.
|
|
|
|
|
I am binding MSChart to a dataset filled with 2 or more datatables. The MsChart is showing only the last datatable. My code is pasted below:
-------------------------------------------------------
Private Sub ProductionChart()
'use collection to collect Selected product
'
Dim Col As New Collection
For Each lst As ListItem In chkWStringList.Items
If lst.Selected Then
Col.Add(lst.Text, lst.Text)
End If
Next
oDs = New DataSet
oDs = oTier.Production3(Col, Date.Parse(Date1.Text), Date.Parse(Date2.Text))
With Chart1
'Create new chart area for original series
Dim ca As ChartArea = .ChartAreas.Add("ca2")
.Titles(0).Text = "Chart"
.Titles(0).Font = New Font("Trebuchet", 14, FontStyle.Bold)
.ChartAreas("ca2").AxisX.TitleFont = New Font("Verdana", 10, FontStyle.Bold)
.ChartAreas("ca2").AxisX.Title = "Date"
.ChartAreas("ca2").AxisY.Title = "Production"
'.Series.Clear()
For j As Integer = 1 To Col.Count
Dim oSeries As Series = New Series(Col.Item(j))
.Series.Add(oSeries)
'Give names to Series
oSeries.Name = Col.Item(j).ToString
.DataSource = oDs.Tables(j - 1)
oSeries.ChartArea = ca.Name
oSeries.ChartType = SeriesChartType.Line
oSeries.XValueMember = "Date"
oSeries.XValueType = Charting.ChartValueType.Date
oSeries.YValueMembers = "Production"
oSeries.BorderWidth = 3
Next
.DataBind()
.Visible = True
End With
End Sub
|
|
|
|
|
aransiola wrote: For j As Integer = 1 To Col.Count
aransiola wrote: .DataSource = oDs.Tables(j - 1)
You get the last datatable as you have written code for that. You have started a for loop and keep changing the datasource depending on the index 'j'. Finally, when the loop comes to an end, 'j-1' has the last table pointed as a reference to datasource leading to data display of last table.
|
|
|
|
|
i am using the loop to add data source for each series i want the chart to show.
|
|
|
|
|
How to export selected items to excel sheet in grid view and save that excel sheet in folder
|
|
|
|
|
|
|
|
Hi iam tarun.......
I need an application for Time slot boooking for room.....plz send me apps to my mail id or send the url to my mail id tarun00197@gmial.com
Thanks in advance
|
|
|
|
|
You do realise that Code Project is not a location where people come to hand out their code for free don't you? If you need a fully written application, and you can't find a suitable one in the articles, then you will have to either write it yourself, or hire someone through Rentacoder.
|
|
|
|
|
It does not work like this here.
Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it's not that hard.
2. Formulate what was done by you that looks like an issue/not working.
Try them and tell if you face issues.
Members will be more than happy to help like this.
|
|
|
|
|
Hope you have seen the Post saying "How to Get answer to your question" in this forum. Please go through it and post any specific issue you are facing.
Thanks & Regards,
Vani Kulkarni
|
|
|
|
|
Start here[^].
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
how to retrieve value of dataset coloumn in c#
I tried b/m but not working
lblreturncode.Text=ds.Tables[0].Columns["item"].ToString();
|
|
|
|
|
try using table mapping name..instead of index (table[0])
|
|
|
|
|
Hi,
Could anyone tell me how to remove session timeout feature from asp.net website.
The session of the user need to be closed only when he/she clicks on logout or close the application or else the webpage has to be in alive state till the time.
Increasing the sessiontimeout in <sessionstate> is also not solving the problem.
Could you tell me how to do it, if possible Could you share a link with example.
|
|
|
|