Good day!
I'm writing a very simple asp mvc 4 app which is a simple static site.
When i send a request from the site to app - I get the following error on my first attempt:
The resource cannot be found.
Description: HTTP 404. The resource you are looking for
(or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /EmailSendApp/login.aspx
On my second attempt, i click "send" and my app works well!
Why is it not working the first time?
Thank you!
It is Intranet site and i use Windows authorization.
It is ASP MVC application with Windows authorization.
In MVC application we cannot write .aspx extension in browser url.In mvc application viewpage extension is .cshtml so please remove .aspx extension in browser url.
Your requested url could be like this http:localhost/EmailSendApp/login
so your request is sent to login method which is present in EmailSendApp controller
Related
I deployed my ASP.NET MVC app to the server. My Site name is: http://server_name/Company_Reports.
Everything works fine except when I redirect to some views.
For example when in .aspx web form I redirect:
Response.Redirect("/FCDReports/DailyReports/");
In my website the site name Company_Reports disappears and the Url becomes:
http://server_name/FCDReports/DailyReports/ and is not found because it should be:
http://server_name/Company_Reports/FCDReports/DailyReports/
How can I keep the site name Company_Reports in the url?
I'd appreciate any help.
Try this in Response.Redirect
Response.Redirect("~/FCDReports/DailyReports/");
Or
Response.Redirect("FCDReports/DailyReports/");
I have not used the WebAPI for Web forms before but have inherited code that uses the WebAPI, so I apologise if this is a stupid question.
From the research I have undertaken today our setup seems fairly basic...
Route Table definition in global.asax
A Controller class that inherits from the ApiController
Ajax calls via jQuery
This all works fine locally and on product sites that do not have SSL certificates. However, the site has an SSL the ajax call produces a 404.
Any help would be greatly appreciated.
Thank You!
Rich
This worked for me:
Go to: IIS -> [your site] -> Handler Mappings
You need to make sure there is a Handler mapped to a path your web service is using, i.e. " */api/* ". In my project there was an existing handler called "Static File" with such a path. It used the StaticFileModule, DefaultDocumentModule, and DirectoryListingModule.
Under "Request Restrictions" set the rules that apply to your project. My settings:
Mapping
- Check "Invoke handler only if request is mapped to:"
- Mark "File or folder"
Verbs
- "All Verbs"
Access
- "Script" (default)
More info about Request Restrictions:
http://technet.microsoft.com/en-us/library/cc730969(v=ws.10).aspx
These settings can most likely be set in your site's Web.config. I'll post my findings when I get that working.
All routes within my ASP.NET URL Routing web application are receiving a 404. However, the actual pages that exist are showing up correctly. I'm using IIS7. Any ideas?
All is good now. The main issue I had was that the HttpHandler for the UrlRouting was not added to the webServer section but rather the "old" handlers section.
I am developing a website using ASP.Net MVC. I have a method in the Home controller which returns a partial view when called. The issue is when I am calling the controller method using jQuery, I get a 404 Not Found error.
This only happens when the application is deployed on IIS 7. It works fine during development, but after deployement, none of the controller are found when called through jQuery.get method or post.
Thanking you all in advance for helping me.
I had the same problem. The simple fix for me was to do a aspnet_regiis -r
is the error an asp.net error (yellow and red) or the default iis7 html error? if its iis7 default error, make sure IIS7 has asp.net installed, that caught me out when i first started working with it. (programs and features and add windows components and make sure asp.net is selected under IIS)
Actually, the website is running, I can navigate among pages, only if there is a call through jQuery.get or post methods, then the error occurs. I guess, there is an issue with ISS 7 regarding recognizing that its a controller method. The error text is given below.
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable .
Thanks.
Make sure you have ASP.NET MVC installed and running. Also, make sure that your application is installed properly with appropriate references.
Like Tony says above, make sure you can actually access the complete URI (controller/method) in a browser to see if it works ok.
what is the URL that the jQuery.get method is accessing?
If it does, check how you have wired your Ajax call.
Do the method in your code have the AcceptVerbs attribute defined? [AcceptVerbs(HttpVerbs.Post)]
If you are deploying your mvc app as a virtual web make sure that BOTH your virtual web and the root site has its Application Pool set as Integrated Pipeline.
If you are running ASP.NET MVC on IIS7, make sure you configure IIS to run in "Integrated Pipeline Mode" as opposed to "Classic". You'll have more success with routing in this mode. More here.
I had same problem.
solved issue by changing the ajax url.
Just for an example ,
if you are using ajax call to the controller:
have to write url as like this == url: '#Url.Action("actionmethod", "controller")',
instead of ===== url: '/controller/actionmethod',
Thanks
Today we tried to put an ASP.NET application I helped to develop on yet another production machine. But this time we got a very weird error.
First of all, from all the ASP.NET pages, only Login.aspx was working. The rest just show a blank screen when they should have redirected to Login.aspx. The HTTP response is 200, but no content.
Even worse - when I try to enter the address of some inexistent ASPX page, I also get HTTP 200! Or, when I enter gibberish in some existing ASPX page code (which should have been accessible without login) I also get HTTP 200.
If I enter the name of some inexistent resource (like asdasd.jpg), I get the expected 404.
The redirect to login page is written manually in Global.asax. That's because the application has to use some alternate methods of authentication as well, so I can't just use Forms Authentication. I would suspect that Global.asax is failing, if not for the working Login page.
Noteworthy facts are also that this machine is both a Domain Controller and has SharePoint installed on it. Although the website in question is listed in SharePoint's exception list.
I would check the following:
Is the application within a virtual application or its own site and not just a virtual directory?
Does the application have it's own App Pool? If it does not then is the app pool shared by apps in a different .net version.
Is the .net version of the application the correct one? 1.1 or 2.0?
Do the files in the file system have the correct permissions to be accessed via IIS?
Have you performed an IIS Reset?
Create a stand alone test.aspx page within your folder that just displays the date/time and check it works.
Make this single test.aspx page perform an exception (eg. divide by zero) and see what the outcome is.
More information required.
What Op Sys?
What mode IIS running under?
What version of .Net?
What version of SharePoint?
(Why are you using your DC as a web host?)
Does it work on the other production machines you've deployed to?
If so what is different between this machine and the working ones?
Did you deploy the same way?
Are you sure your hitting the right machine?
Are you sure your hitting the right web site?
What ISAPI components are installed globally and for the web site?
Is .aspx mapped to the ASP.Net ISAPI filter?
Do you have any HTTP Modules or HTTP Handlers configured?
Can you change the global aspx to write out some messages so you can be sure the piece of code you interested in is reaching?
Anything coming up on the IIS log or the event logs?
Addition:
What version of .Net?
By the sounds of it the .jpg request is being dealt with by IIS directly which is why you get the 404, but the .aspx request is being dealt with by something else which except for you login page, is always returning 200.
Assuming .aspx is wired correctly to .Net the the order of processing is based on ISAPI filters (high to low then global before site), then the ASP.Net ISAPI Extension (sorry I said this was a filter earlier but it's actually an extension). Then we get into the ASP.Net pipeline based on your .Net configs, and calls the HTTP Application (which includes your global.asax code), any HTTP Modules followed finally by a HTTP Handler. Your ASP.Net web forms are just fancy HTTP Handlers.
However, the request can be responded to and terminated from any point.
Since your code works on other machines though, I'm tempted to point a finger at SharePoint if it isn't installed on the working machines. Is this SharePoint 2007? That is also an ASP.Net application (I don't think 2003 was).