This happened on ASP MVC.
When i tried to get access files from "Views" it can't read it.
I tried to get it showing like localhost:6036/Home(file content) and not like localhost:6036/Home/Home(file content)
already tried to move Home.cstml to any folder but it didn't work at all. it still gets me a message server error "/"
and now this is what my href looks like on "_Layout.cstml"
href="~/Views/Home">
So is there any possible to get "localhost:6036/(this is a directory file which i can access)"
If yes, how to that?
Thanks.
As you can see in the link below, MVC denies direct access to your views (that ends either in aspx/ascx, either in cshtml/ vbhtml) :
https://forums.asp.net/t/1799101.aspx?How+deny+access+direct+URL+to+my+partial+views+
If you just want to share a file (like an image, or anything else) you should use the "Content" folder.
Hope it helps !
Related
Heloo,
I have website that built by SPIP and already online on the internet. Since my webmaster dont work anymore with us, now I try to learning CMS SPIP.
I want to edit one of the html file, located inside this directory : httpdocs/squelettes/myfile.html. Say the name of my file is myfile.html
I changed some part of the file than upload it through fileZile. When I open my browser and refresh it, the file haven't changed yet. but it's successful upload.
please advise, do we need to configure something to upload the file.
Thank you for your help
There is a simple way to refresh a page in SPIP when you have caching issues : pressing the Reprocess page button on the public site (as said by Serge) or adding ?var_mode=recalcul as a parameter of your URL.
I think the matter is in website cache. SPIP is hard caching HTML and images.
Try to clean cache via private area (under Maintenance button in SPIP 3) or press "Reprocess page" button on the front-end.
With your FTP connection go to the SPIP root directory, then find the /tmp directory open it and clear\empty the /cache directory inside it. This directory contains temporary files & cache files.
I need to confirm ownership of domain, as instruction says, place special .html file in main directory.
It confused me. Tutorial says, that file should be avaliable as www.domain.com/file.html
I placed it in views folder, but nothing. I wouldn't like to set special controller-action-route for that(it is quite weird), but looks like I should? Or other way?
How do I do that in terms of Rails app?
Just put file.html under the public folder, and visit www.domain.com/file.html
In Rails everything within the public folder is visible to the outside world.
I have used paperclip to allow me to upload files to a rails application. Everything works and the file is uploaded, but instead of seeing a link to the actual file itself I see the location of it within the systems folder of the rails project.
I'm guessing its either a routing issue or I need to create a link to the file in question. However, I would like to hide the location of the file itself, and only see the link displayed.
I would be very grateful if someone could point me in the right direction here.
You want to hide the actual path of the file in the server, right?
You can achieve that using send_file (http://api.rubyonrails.org/classes/ActionController/DataStreaming.html#method-i-send_file) in a normal controller.
You will still need to do something to protect the download using the real path.
Basically, this is what my app does:
It sends an AJAX request
The server creates a file
The server sends back the URL of the
file location
The client-side will attempt to
create a dialog to download the file
at that location (probably using a
frame? I haven't got this far yet).
My question is, how do I dynamically route to the files I create so that they are accessible when you browse to them? If I don't add a route for them, then they will get a 404 if they try and access the directory they're in.
The files are currently stored in a folder in public.
Would the best way to deal with this make the folder somehow not require a route, so that it can be browsed to directly, and then have an index page on it so they can't view the full list of files? If so, please let me know how I can accomplish this. And on a side note, if you have an idea of how I can accomplish JS displaying the download dialog let me know.
It's Rails 3 by the way.
Thanks!
For a full private set of files: choose a place for your files outside your public directory, then configure X-SendFile support in your web server and finally use send_file in your rails application.
I have an ASP.NET MVC website that works in tandem with a Windows Service that processes file uploads. For easy maintenance of the site, I'd like the log file for the Windows Service to be accessible (to me, only) via the website, so that I can hit http://myserver/logs/myservice to view the contents of the log file. How can I do that?
At a guess, I could either have the service write its log file in a "Logs" folder at the top level of the site, or I could leave it where it is and set up a virtual directory to point to it. Which of these is better - or is there another, better way?
Wherever the file is stored, I can see that there's going to be another problem. I tried out the first option (Logs folder in my website), but when I try to access the file via HTTP I get an error:
The process cannot access the file 'foo' because it is being used by another process.
Now, I know from experience that my service keeps the file locked for writing while it's running, but that I can still open the file in Notepad to view the current contents. (I'm surprised that IIS insists on write access, if that's what's happening).
How can I get around that? Do I really have to write a handler to read the file and serve it to the browser myself? Or can I fix this with configuration or somesuch?
PS. I'm using IIS7 if that helps.
Unfortunately I'm afraid you'll have to write a handler that will open the file, and return it to the client.
I've written an IIS Manager extension that displays server log files, and what I've noticed that even the simple
System.IO.File.OpenRead("")
can still run in the same problem, and return the same error.. It was kind of confusing.
In the end I used
System.IO.File.Open("", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
and I could easily open the file while the server was writing logs to it :)
I think the virtual directory is an "okay" solution, if you add the directory (application) with READ ONLY rights + perhaps "BROWSE directory" too (so you can see the folder contents rendered by the IIS).
(But once you do that, you should consider that you also anonymous access to that folder - unless you enable authentication, so watch out for "secret" contents of the logfiles that you might expose? just a thought.)
Another approach, I prefer myself, is to make a MVC/ASP.NET page that does the lookup in the folder by normal code, so that you 100% can filter whatever data is shown in the HTML.
You can open the files as TextStream's and in Read Only mode.
If it's a problem to gain access to the logfolder, I would use the virtual directory with READ ONLY access and then program something that renders the logfiles as HTML on my screen and with my detail levels. Perhaps even add some sort of "login" first. But it all depends on your security levels and contents of logfiles.
is this meaningfull to you? if not, please explain more, as I've been through this thought a few times already for similar situations.