My windows service needs to connect to a specific HTTP folder (IIS 7) and list the files inside and then start downloading them one by one. Is there any real professional way rather than parsing HTML tags to get the file name (which most likely will cause problems).
Not unless you have directory browsing setup on IIS.
Is this your server or a thirdparty site you're trying to scrape? If you don't have control of the server you may not have a choice.
Related
I have VS 2015 and a smallish C# web app. I can debug it on my desktop without issue. I have setup Web Deploy and have deployed the app to a dev server. The puzzling thing is that there are a couple of files that exist on the dev site that are not being served by the IIS server.
In my app I created a "LocalContent" folder at the same level as Views, Models, Scripts, etc with this structure
.../LocalContent/css
.../LocalContent/css/index.css
.../LocalContent/js
.../LocalContent/js/index.js
I can see the BuildAction property for the index.{css,js} files is set to Content and they do exist on the dev server.
When I load the dev site these resources both throw 403 errors (as seen through Chrome's Dev Tools). Not only that, looking at the URIs to these resources does not, for example, give .../LocalContent/css/index.css. Instead the dev-tools networking display shows something more like: .../LocalContent/css/?v=<long string of garble>.
This is my first IIS deployment so I am not sure what is or should be going on. Do I need to do something terribly Microsofty after each Publish event and restart the IIS process or reboot the IIS server machine?
These files are likely being served by IIS's static file handler, which acts as a different identity to your application pool.
Assuming your server is configured with defaults, granting the IUSR user access to your web root (or at least the specific directory)\ that contain the static files) should solve your problem.
What is the best way to get files from client folder (a folder that the client will choose the path) and upload to server?
Thanks.
You can't.
For privacy reasons, code from web sites running in a browser context is not allowed to enumerate files or directories on the client machine and send that information to a server. Imagine what would happen if it could!
You could possibly get around this limitation with some more complicated solution that includes a client side install (e.g. an ActiveX control) but this is simply not possible with ASP.NET alone.
Process.Start() will start a process on the machine where the method is called. In the case of an ASP.NET application, this starts the process on the web server, rather than the client. This works correctly in testing when your server and client are both the same machine.
Is there any way to open those files just like we open in windows so that user can edit it, n on CLT+S it can save to the respective directory in the SERVER.
NOTE: I have already mapped the server directory location to network path. (J:)
No, this is not possible. You cannot open files on the client machine from a serverside web application, nor is this possible directly from the browser because of security reasons.
Options are:
Letting the user download a file from your server, have them edit it and then re-upload it with their changes.
Creating a browser extension / plugin that does this, so the user doesn't have to manually open their editor and upload the file again.
Create an editor like Google Docs / Office 365, so users can edit serverside documents in their browser.
I have built a web application which uses two web front end servers, the Users are randomly directed to either one through the same URL. The web app has specific functionality to upload and download files. When a file is uploaded, it is stored on a specific directory on the server to which it is uploaded.
The issue is that when a User uploads a file to the folder on Server 1, any user trying to download that same file from Server 2 will not be able to as it only exists on the server where it was uploaded.
What's the best way of solving this? I've looking at:
- Using a SAN, problem here is I don't want to change or create a domain
- Writing a Windows Service, would prefer to avoid this if possible, I've not done it before but will give it a go if necessary
Thanks in advance!
Joe
Unless I'm missing something very obvious, all you need is a shared location. This could be a network share addressed through a UNC path, a folder on an FTP server, a database, anything at all, as long as it's
shared,
accessible from both web-servers
web-application service account has read/write permissions to it.
From your requirements a network share on a file server (perhaps 1 of the 2 web-servers, or the load-balancer, or (ideally) a new server entirely) would be the simplest method.
I am building my own web server and want to serve from it a Silverlight application. Is there anything else I have to do besides setting the mime type and pushing the application through the wire?
It probably makes no difference, but the web-server is in C# (the micro-edition).
No, silverlight is all run on the client, so unless you want to do some webservices or whatever, you needn't do anything other than set the mime-type.
It is really just like a separate file that you serve to the client, just like any image, script or css file.
If you are developing a single Silverlight application that you want to deliver then you need only serve the XAP.
However if you are not the application developer or you want to deliver multiple apps effeciently then your web server needs also to be able to deliver other files that may come along with these apps. For example the libraries may be be delivered as zip files and they may download external images and XML files. Still this is all likely to be simple static content you will not normally need to implement other services.
Note if you are hosting an app to be referenced by a HTML file served by some other server then you need to get your site to respond with appropriate XML when SL requests the clientaccesspolicy.xml file.