I have a C# MVC 4.5 Website where everything works as expected, until recently, when I added a new folder.
It was meant to house CMS-type applications and keep them separate from the main site. As I built these apps I checked everything on my local instance of the site, and it all looked fine.
However, since I pushed the updates to DEV, I'm getting some odd and unexpected results - displayed below.
Here's a pseudo-file structure:
Solution 'MySite'
MySite
Controllers
Images // Images from this folder appear normally
Models
Scripts // Scripts from this folder load normally
Views
Admin
AdminApplication
Index.cshtml
Shared
admin_common.css // 500 error
admin_common.js // 500 error
Images
banner.jpg // will not load
Keep in mind all these issue are only on Dev, everything on local is fine. It seems very weird that a css file would load, but not have any content.
This is how the styles and scripts load in the layout:
#Scripts.Render("~/Shared/jquery.js") // loads fine
#Scripts.Render("~/Admin/Shared/admin_common.js") // 500
#Syle.Render("~/Admin/Shared/admin_common.css") // 500
Here's what I've tried:
I looked at log files, but they all say the files loaded fine. I only see 200's, no 500's.
I looked at the static content option in IIS, as seen here: http://adilmughal.com/blog/2011/11/iis-7-not-loading-css-and-image/ but it's an IIS-wide option rather than folder-specific.
When I visit the URL of the css, I get 500: Server Error [10-0002] so I looked for that, but the only thing that seemed useful was this, https://communities.ca.com/thread/110605407, a deep comment said their isapi file was missing. I checked my web.config file, and tracked down the isapi files, and they looked fine.
I tried the Failed Request Tracing, as specified here: IIS 7 gives me error 500 internal server error when trying to display my XML document, but there were no logs there, even though it was on.... which is weird, but not what this question concerns.
I also tried adding an httperror line to web.config like this says: https://serverfault.com/questions/407954/how-to-diagnose-a-500-internal-server-error-on-iis-7-5-when-nothing-is-written-t. It should give better errors, but it doesn't.
What is causing my development machine to not display this necessary content?
TL;DR: an unnecessary web.config file with missing isapi handlers.
When I first started the new folder, Admin, I wasn't sure how it would work. I read somewhere that it would need it's own web.config file. So I copied a bare-bones web.config file from somewhere into the new folder.
Later on, I changed the name of it to web.bonfig, to make it inactive (b for backup).
My current theory is perhaps there is a different precedence of conflicting config files on the servers (but where would something like that even be defined?). This morning I changed the file name to web.bonfig.backup-ignore from a Windows Explorer window and that seemed to have fixed my issue.
BTW web.bonfig only had one handler defined in system.webServer. This would suggest that solution 3 in my question was the correct solution, but I was looking in the wrong config file.
Related
I am trying to build my first ever API and I want it to read some text from a .txt file.
I wrote the code originally to have the text be stored in memory and then remove it after the HTTP Get request. I had it working properly when I would run it in Visual Studio, so I decided to deploy it to Azure. I would then make the HTTP request to add more text into the memory and then I would essentially request it back, however I wouldn't get the text I wanted back. Instead I would get my error message saying that there is nothing in the list which holds the text I want.
I then decided to have it write the text to a .txt file then receive it from that. Once again this worked on my side, but once I published the code to Azure and send a request, I get a 500 Internal Server Error.
At the end of this long story is my question since I can't seem to find any details about .txt files on an Azure Web server.
Is it possible to have my C# class's in my Models folder of my API Web app read a .txt file on an Azure server?
Is it possible to have my C# class's in my Models folder of my API Web app read a .txt file on an Azure server?
The short answer: yes.
The slightly longer answer: yes, however...
As posted in the comments reading and writing information to and from a file in a web application can go bad really fast. Think about two users trying to write at the same time, one user reading at the moment another one is writing and so on.
Now I can imagine the only thing you want to do right now is test to see if it works, so multiple users might not be on top of mind. But even a proof of concept deserves the correct approach, since you might learn something the wrong way otherwise.
Have a look at storing your information in a data store inside Azure, there are quite a few options. For this just to work, it's probably best to use something that's not too hard to set up like Table Storage. If you run into any issues trying to get this to work, open up a new question and we'll be happy to help.
500 Internal Server Error, these is general error in server side. I reproduce same problem and its working fine by using following steps.
After deploy on Azure its show 500 error.
you find actual error to enable Application Insights and go to Failures tab. You can see actual error why occurred.
Click on Error
See Error and File location.
Check File location, if file not there location then create a file on that location. Go to advance tool
Click to go link.
Select Cmd from Debug console dropdown. and click on Site->wwwroot
Create a txt file
Output : Now its working.
I have 50 SAME asp.net websites hosted on IIS. Something like WordPress, where each website though same has different content.
C:\inetpub\vhosts\website1.com
C:\inetpub\vhosts\website2.com
C:\inetpub\vhosts\website3.com
.
.
.
C:\inetpub\vhosts\website50.com
Since these are exactly same copies of the ASP.NET website; I want to use a 'common' bin folder so that I don't load 50 copies of the same set of DLLs to update and load in memory each time.
The solutions here: Is there a way to change .net mvc bin dir location? DO NOT work as I want the DLLs to be placed outside the website folder, so that they can be shared.
One little detail you should know about IIS and ASP.NET; they do not actually run the files in the bin folder. Rather, they copy the files in the bin folder into a "shadow directory" (something like "C:\WINDOWS\Microsoft.NET\Framework\v4.5.XXXX\Temporary ASP.NET Files"). It is from there that they are actually executed. The bin folder is monitored for any changes, and the shadow directory is updated as needed. This allows you to deploy new DLLs even when the site is running-- otherwise, they'd be locked.
So... no matter what you do, the O/S is going to load multiple images of the same DLL, even if you get them to all use the same bin folder. As far as I know there is no way to turn this off.
That being said, if you want to save a bit of disk space and get your sites to use a common bin folder, consider using a symbolic link. This essentially allows you to create a directory that "points" at another directory (this sort of thing is more common in Unix). Thus you end up with one copy being accessed from several places. Just one word of caution: be very careful when deleting things, because you could delete folders from all 50 of your sites without meaning to.
But a better option (depending on why you are running 50 identical sites, which is very unusual) is to run just ONE site, with one IP address, but with several DNS entries pointed at that IP. This way it would look like you have 50 sites when you only have one. The trick here is (if you are using https) you'll have to use host headers to pick the SSL cert so that browsers don't show a phishing warning. Or, if your site is load balanced, you could terminate SSL at the load balancer (a strategy known as SSL offloading) so that a cert at the IIS level isn't even needed.
Ive been away from .Net web dev for a few years and am now coming back to it inorder to update a client project. I've installed VS Pro 2015(legit no cracks) and am now experiencings some odd behaviours both with the project/website files and VS.
The first 'issue' I need to tackle is that when adding a new master page or webform to the project, these new documents appear completely empty. There is no code or markup generated in the documents eg: 'docname.master', 'docname.master.cs', 'pagename.aspx', 'pagename.aspx.cs'.
I doubt this is the correct, behaviour since it wasn't in the past. So have things changed, and this is expected, and I need to get up to speed. Or, is there something wrong with my set-up -which I expect- ? If so, do you have any ideas what I'm doing wrong? What can I do to rectify this?
UPDATE
I've just done some testing on a different machine and it appears that this seems to be connected to the fact that the files I've been working with are located on a network file server. Is this a known issue, and are there any fixes/workarounds?
In my case it turns out that the cause of this and several other issues was purely down to the fact that the project files I was working with were located on a network drive.
It appears that this is a fairly common problem, especially when access to the network / remote drive is quite slow.
Simply switching the project files to a local drive fixed all the problem I was experiencing.
Running my C# application from Visual studio works fine (in this respect)
But when installing the application in my system (win7, .NET 4.0) I get problems with the cache.
These are the errors I get:
LogMessageCallback. Message:20:43:03.988 E [playlist:1978] Unable to save file: playlist.bnk
LogMessageCallback. Message:20:43:03.988 E [social-mgr:830] Unable to save file: social_stream.bnk
LogMessageCallback. Message:20:46:31.034 E [user_cache:107] Unable to save file: user-cache.bnk
LogMessageCallback. Message:20:43:04.988 I [c:/Users/spotify-buildagent/BuildAgent/work/1e0ce8a77adfb2dc/client/core/protocol/file_streamer_simple.cpp:769] Request for file 57a6ab34bad26645e2345a610ae652fe77f82afb complete (code: 0)
I have tried to deleted the entire cache library and it gets recreated when I start the app, so it can't be a matter of file privilege.
Since the cache does not seem to be valid my playlists are not accessible to me at startup.
I do log out properly.
Any explanation/workaround?
I think I've got it...
I search for the playlist.bnk file on my disk and found one under Spotify\bin\Debug\cache_location\Users\bes51659-user, that is from where I run my project with visual studio. "cache_location" in the path directed me to the settings_location argument in the config struct when creating the session. I had set it to const string "cache_location". I must have understood the explanation wrong:
https://developer.spotify.com/docs/libspotify/12.1.51/structsp__session__config.html#a342532432040d476aaaf73f10893d23b
The location where Spotify will write setting files and per-user cache items. This includes playlists, track metadata, etc. 'settings_location' may be the same path as 'cache_location'. 'settings_location' folder will not be created (unlike 'cache_location'), if you don't want to create the folder yourself, you can set 'settings_location' to 'cache_location'.
(a bit contradictory that the "cache_location" catalog was actually created under debug!)
The comment must mean that if I reuse the same location for setting_location as for cache_location I do not have to create it as it has already been created!
I do not know if libspotify did not have permissions to create the catalog "cache_location" under "program files", or if it expected it to be there and did not find it. But it does not matter. I have now changed both the locations to "c:\mySpotify" in the config struct and problem solved...
My only excuse is that google tells me that I'm not the first to have fallen into this pithole.
We are testing out our SP site on a staging environment (we do have access to hive logs, but haven't had much help with them) and we're getting a very strange error that doesn't show up in our dev environment.
When uploading a document to a document library (these are doc libs created with a custom content type), after filling in the properties and clicking check in, I get an error "Item does not exist The page you selected contains an item that does not exist. It may have been deleted by another user." I cannot figure out why this is happening, and it can't be replicated in the dev env.
Weird 'workaround' that we figured out to force it to check in.. after getting the error page, click back to go back to the edit page, refresh the page, then check in. This works every time without error.
Another note, it seems to only happen after a document has been added recently. The first document added to the lib always checks in perfectly fine, but always the 2nd or 3rd document will get this error. After that it has a high chance of happening.
Any clues? We have an older code base (which honestly isn't all that different) on our production server that works fine, and the staging and production environments are identical.
The error seems to occur during the EnsureItemIsValid() method according to the error stack trace (which occurs at some point during the SaveButton.SaveItem() method). We have an ItemUpdated event with this content type, however it appears to be getting through that just fine.