WebMatrix Giving 404 with UrlRouting - webmatrix

I've been trying to follow these two links on how WebMatrix does URL Routing
http://www.mikesdotnetting.com/Article/165/WebMatrix-URLs-UrlData-and-Routing-for-SEO
http://www.asp.net/web-pages/tutorials/working-with-pages/18-customizing-site-wide-behavior
From my understanding, for something like http://localhost:44893/a/xyz
WebMatrix will first for a file name /a/xyz.cshtml and if that isn't found then it will check for /a.cshtml and if that isn't found then it will check for /a/default.cshtml
I created an empty site in WebMatrix 2 Beta ( 3/5 Refresh ). I created a folder name a and created a default.cshtml file inside.
If I go to http://localhost:44893/a, I'll get the default page but if I go to http://localhost:44893/a/xyz, I'll get
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://localhost:44893/a/xyz
Physical Path C:\Code\Test\a\xyz
Logon Method Anonymous
Logon User Anonymous
Is there anything that I'm missing to setup this up?

You missed this part of the article:
If no matches are found during the search for files, Web Pages will
attempt to locate a default document instead. The two default
documents which work are default.cshtml and index.cshtml in that
order. However, this search is performed once, and assumes that the
URL is entirely a file path, and contains no UrlData.
The built-in routing system will always assume that the URL represents a file path. The only time a default document comes into play is when the system has already determined that a/xyz.cshtml doesn't exists, so tries to establish if xyz is a folder containing a default document. If a/xyz/default.cshtml (or index.cshtml) doesn't exist, no further attempts are made to locate a default document while trying to match this particular URL to a file path.

Related

Unable to locate the model you have specified - All i did was change servers

I have a codeigniter website, using the latest version of the frame work. I was hosting my website on Azure, and it was working fine - never any issues.
I've just moved all the files to a different server, a linux one - standard normal web hosting type server with cpanel.
My site loads up, however a lot of pages I use that require models, are giving off errors, as if the files do not exist
Unable to locate the model you have specified: UsersModel
Just note : I have read so many articles today, that you need to have uppercase / lowercase and all that stuff, but that's how i already have it setup, it just does not work since changing servers. and it worked perfectly fine yesterday on the Azure server.
Also, when going to the actual file in my address bar, it takes me to the 404 error. not sure if this has anything to do with it?
Did you change your base url in config file ?
All model , controllers, helper ,library name must me capital letter.
If you change server remove index.php from config file where you will get config['index']= ""; and save this.
Still you get error then save base url like domain/project_name/index.php

Custom error handling

I am developing a component in joomla 2.5, my component sends a request to some url and gets the response object. If i pass wrong url, joomla takes me to the default page of Error : 500 - No response code found . I want that if user install my component and mistakenly they put wrong url , it should show some custom error message/page which should more meaningful to non-programming person rather than taking user to default error page. Is there some way to add this type of functionality in Joomla without editing template/error.php file in core.
You should have an error.php file in your template, if you don't add one and make it look the way you want. also remember that when you turn debugging off you won't get the stack trace etc.
However error 500 indicates something different than that the url does not exist ("wrong URL"), which would be a 404. 500 is an internal server error and you need to check your logs to figure out what is causing it.

No admin data found

I tried to claim "Insight for my website" and i get the error "No admin data found at root webpage http://akcja-nikon.pl/. Insights requires admin data at this root webpage for the specified URL akcja-nikon.pl"
Admin tag data is there, i triple checked it, on both index.php and pickup.php (index redirects to pickup - in case you ask). I've done it almost a hundred times on all my other domains and never had a problem with that. I started having issues last week on this and one more domains.
Debugger scraps weird content for the URL an breaks after the first line on the HTML code
https://developers.facebook.com/tools/debug/og/object?q=akcja-nikon.pl%2Fpickup.php
and flags the error in red "Can't Download: Could not retrieve data from URL."
Any ideas? Maybe some weird Facebook cache?
Admin tag data is there, i triple checked it, on both index.php and pickup.php (index redirects to pickup - in case you ask).
No, it does not.
Your index.php redirects to agegate.php via JavaScript – which the Facebook scraper doesn’t care about.
And calling agegate.php directly, without any cookies set (which the scraper does not care for either), delivers a just an error message,
<br />
<b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in <b>/home/marketingpic/include-pl.php</b> on line <b>38</b>
together with an HTTP status code 302 Moved Temporarily and a faulty Location header that just says Location: pickup.php. (Faulty, because a fully qualified URL is required as value for a Location header by definition.)
And if I call your pickup.php, again without any cookies, it tries to send me back to index.php again (and again with a faulty Location header).
No idea, what exactly you are trying to accomplish here – but the way you are doing it right now, seems to be quite a nonsense.

500 error when integrating multiple apps in one code base

I'm trying to set up an MVC application that will service several facebook applications for various clients. With help from Prabir's blog post I was able to set this up with v5.2.1 and it is working well, with one exception.
At first, I had only set up two "clients", one called DemoStore and the first client, ClientA. The application determines what client content and facebook settings to use based on the url. example canvasUrl: http://my_domain.com/client_name/
This works for ClientA, but for some reason when I try any DemoStore routes I get a 500 error. The error page points to an issue with the web.config.
Config Error:
Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'facebookredirect.axd'
I am able to add additional clients with no problem, and changing DemoStore to something like "demo" while using the same facebook application settings works fine also.
Working calls:
http:// localhost:2888/ClientA/
http:// localhost:2888/ClientB/
http:// localhost:2888/Demo/
Failing call:
http:// localhost:2888/DemoStore/
I was thinking this might be an MVC issue, but the Config Error points to the facebookredirect handler. Why would the SDK try to add this value to the config during runtime, and only for this specific client?
Any insight would be greatly appreciated.
I managed to figure out what went wrong here. Silly mistake..
After I had set up the application routes to require the client_name I changed the Project Url in the project properties to point to demostore by default. When I hit ctrl+S a dialog popped up that I promptly entered through without reading.
When I changed the Project Url, IIS Express created a new virtual directory for the project. This was the source of my problem. Why? I'm not sure, but once I removed the second site from my applicationhost.config I was able to access the DemoStore routes.
Moral of the story: read the VS dialog messages!

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'http://schemas.xmlsoap.org/soap/encoding/'

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'http://schemas.xmlsoap.org/soap/encoding/'
First, I am sorry to say I put these question here cause so many same question in stackoverflow. But it seems not any fit for me.
I use Magento SOAP2 API for times, this error not happed often. But it keeps make a fatal error when I run my script today.
I have looked up for some method to solve this problem, for example, some articles told me to change this code in /app/code/core/Mage/Api/etc/wsdl.xml
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemalocation="http://schemas.xmlsoap.org/soap/encoding/">
</import>
to this
<!--
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
-->
I followed this, but it make another error like below,
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: unexpected <import> in schema
Then I have no idea what's wrong, cause this script is always running perfectly but today and I even do not change any line of the code. My question is,
1, Any method to solve it?
2, Can I make this xmlsoap.org xml file to localhost or my own server so that my script will not depend on a file out my server.
Thank you in advance!
First of all, please never tamper with the default elements of any Magento API V2 WSDL Configuration file. It's a basic rule.
Please keep in mind to write these following elements at the beginning of each custom WSDL file or make sure that these following elements are present at the beginning of the WSDL file of your target existing module:-
"definition" element (<definitions> - start tag)
"types" element (<types> - start tag)
"schema" element (<schema> - start tag)
"import" element (<import /> - singleton tag, with no end tag)
Then you can continue with defining the Complex Data Types of the Magento API V2 for that Custom Module.
You can very well get the concept of all these by looking into some of the existing Magento API V2 WSDL files.
Now coming back to your questions...
1. Any method to solve it?
As I said before, please maintain the above-mentioned elements definitions at the beginning of your WSDL file.
The "import" statement should have been:-
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
with no end tag.
Also the attribute name is "schemaLocation" & not "schemalocation". Follow the Camel Casing please.
2. Can I make this xmlsoap.org xml file to localhost or my own server so that my script will not depend on a file out my server?
Yes you can, but you need to know & maintain two vital points:-
Both of the attributes "namespace" & "schemaLocation" must be of type URI, according to the W3C specifications. So your local files for both of these attributes must also be accessible in your local browser, using HTTP protocol.
If you are maintaining it in your local hard disk, then you are forgetting about one golden rule of upgradation, for Schema of the SOAP/1.1 encoding file. This is because if (only if) W3C upgrades this file in this same URI, then your Magento will be able to take it automatically if the general URI is provided; otherwise you will need to download that upgraded file again to your server.
Other than these two major points, everything is okay & you are good to go.
Nevertheless, I hope that I have answered all your queries. Hope it helps.
Use code like,
//create soap object
`$proxy = new SoapClient('http://localhost/magento/index.php/api/soap/?wsdl');`
// create authorized session id using api user name and api key
$sessionId = $proxy->login('apiUser', 'apiKey');
$productinfo = $proxy->call($sessionId, 'product.info',16);
echo "<pre>";print_r($productinfo);
Just some details for accepted solution.
Enter the address of the schema location in your browser:
http://schemas.xmlsoap.org/soap/encoding/
Save the XML result in the browser in a file called encoding.xsd (save file as).
Copy this file to your magento web root directory e.g. /var/www/magento/
Search for all schemaLocation entries in wsd*.xml files from magento root folder with e.g. find . -name "wsdl*.xml" | xargs grep schemaLocation 2>/dev/null | grep org
On my system 12 matching files in ./app/code/core and 2 matching files from 3rd party extensions in ./app/code/local.
Change the line in every matching xml file
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"
schemalocation="http://schemas.xmlsoap.org/soap/encoding/">
to
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="../../../../encoding.xsd">
Remark: In this case the encoding.xsd file is 4 directories higher relativ to the api path of http://sampleshop.com/testsystem/index.php/api/v2_soap/?wsdl
In your live system 2 (without index.php) or 3 (with index.php) times "../" could be correct.
Try the SOAP calls from local and remote server
Example Script
<?php
$proxy = new SoapClient('http://sampleshop.com/testsystem/index.php/api/v2_soap/?wsdl');
$sessionId = $proxy->login('MagentoSoapUser', 'SoapApiKey');
$result = $proxy->directoryCountryList($sessionId);
var_dump($result);
?>
This solutions worked for me, just wanted to add some details as it takes me some time to get it running.
System: magento CE 1.7.0.2
SOAP: php-soap with php version 5.3 on magento server and 5.6 on remote server.
Kozure

Resources