I've hosted my Visual Studio project on somee.com and I'm having trouble setting it up there. I've uploaded all the files of the Visual Studio Project (data layer, lib, model layer, sln file, suo file).
I found out that in order to assign the default page you need to write that in the web config file. I've written the following lines in my web config file.
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="www.omsshutter.somee.com/www.omsshutter.somee.com/Shutter 2000 Halloween/login.aspx"/>
</files>
</defaultDocument>
</system.webServer>
The login.aspx page which I want to be the default page does not come up. It's in the "Shutter 2000 Halloween" folder. How can get this working?
You need to use relative path to file instead of full HTTP path. i.e. Use following line
<add value="Shutter 2000 Halloween/login.aspx"/>
instead of
<add value="www.omsshutter.somee.com/www.omsshutter.somee.com/Shutter 2000 Halloween/login.aspx"/>
Method 1
You can always check the user state secured/user-visible master page.
If user isnt logged in from master page load simple redirect to login page (having public master page) using.
Server.Transfer("~/login.aspx");
Method 2
In your Global.asax.cs file, write the following:
public void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes routeCollection;
routeCollection.MapPageRoute("DefaultRoute", string.Empty, "~/YourDesiredSubFolder/YourDesiredDocument.aspx");
}
Explanation:
Application_Start code is guaranteed to run once and only once on the
application start.
The first line of code, gets a collection of the
URL routes for your application.
The second line of code, defines a
new route pointing to your inner page in the subfolder that you wish.
The second argument is empty to indicate that this route is used when
there's no specific page is requested and there's no Default document
existing.
Related
I have an ASP.Net application. The application is working when the url is http://locahost/device.aspx but not working when the given url is just http://locahost. It is throwing an IIS exception and the IIS image is displayed when http://locahost is given
IIS image displayed
If you are using IIS, you need to set the default page in your IIS server. You can check the steps online as it varies from version to version.
Another way thorough web.config, you need to add following tag in your web.config file
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="device.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Because you don't have a default.aspx page.
IIS searchs the Default.aspx if you don't define in the url the page that you want to display . If Default.aspx doesn't exist, it can't decide which page to display.
If you don't have a Default aspx, you should add your device.aspx in the iis manager to your site like on the image.
First, you should open the iis manager (you can type Windows + R to execute the command inetmgr in order to open the iis manager).
Than you expand the server and Default Web site and choose your application.
Double click on the Default Documents and add a new default documents like on the image.
If you want to refer the default web site to your application in order to use only http://localhost url, you can configure your iis like on the second image
I am working on hosting a website developed using asp.net to AWS. I have successfully published it to EC2 instance. I want to setup Index.aspx page as default page so that if someone open the URL it should automatically load index.aspx page e.g. typing www.domain.com opens up index.aspx page. I have tried all the options but somehow its not working for me. Any suggestions will be highly appreciated.
For IIS Web Server you should look at the web.config file.
Make sure you have <defaultDocument enabled="true">
The default files in recent IIS version are (in order)
index.htm
index.html
default.asp
default.aspx
index.asp
index.aspx
index.cfm
index.php
default.htm
If you don't enable the default list, you would need to make sure your index file is added to the list
<defaultDocument>
<files>
<add value="index.aspx"/>
<add value="..."/>
</files>
</defaultDocument>
I'm developing web service on Visual Studio development server. Browser starts at project root directory and shows files list. I always must select required asmx file to run some tests. Is it possible to ask debugger to show webpage on required asmx address instead of directory list?
You can set default document on web.config file for specific asmx file name.
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="TestService.asmx" />
</files>
</defaultDocument>
</system.webServer>
Visual Studio runs the page that was currently in focus in your designer.
If you set this page, Visual web Developer will start your web site with the Set Page and not the current page in designer.
You can do this by right-click on the page and selecting Set As Start Page option from the context menu.
I have a WebApp with an upload section.
To upload the files to a sql database I'm using a Ajax Toolkit Fileupload control.
I always get a similar error as in this post, but after hours of testing, I figured out what is causing my Problem.
My upload control is located on the SidDetails.aspx page and if open the page directly
with
foo.com/Pages/SID/SidDetails.aspx
I'm able to upload files.
but if I access the page via the route
foo.com/SID/My/1
I get a 500 internal server error
So I checked the link of the page that is causing the exception
foo.com/SID/My/1/?contextKey={DA8BEDC8-B952-4d5d-8CC2-59FE922E2923}&done=1&guid=BD327457-2013-1E97-6ADE-28612D63758E
For me, it looks like that is the problem, but I don't know how to fix this.
I already tried adding a route with query value
But i don't know if this is how you would approach it.
Could not find a part of the path 'C:\Windows\TEMP_AjaxFileUpload\E0E386A6-F5B5-1012-F6E5-1872E4D6EF69'.
Thats the exception that is thrown by the upload control.
I would like to keep the routes but how can I fix the problem?
I'm using Visual Studio 2012, .net 4.5 and AjaxControlToolkit 7.0930
Kind regards
CarnVanBeck
I run into this too, and after going crazy I fixed it.
Download the ajaxtoolkit source code project and open it.
Change the following row:
this._uploadUrl = 'AjaxFileUploadHandler.axd';
to:
this._uploadUrl = '/AjaxFileUploadHandler.axd';
Rebuild the project, get the new .dll and copy it to your /bin directory.
This will fix the issue, giving the right path to the handler.
PS: I came to this as:
I noticed some strange duplicated calls to the handler, happening only in routed paths
(like www.site.com/projects/edit/mypage), where uploads failed.
I noticed that in a test page, placed in the home dir of my site, the uploader was working fine.
Then I came to this page and noticed the mentioned row.
If your app is running in Integrated Mode pool, you have to add this lines in the web.config file:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd"
type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
I have a project that works with bundling when you run it from within visual studio. However, after you do a deployment, the bundling handler never seems to pick up the route. It ends up going to the static file handler instead, which returns a 404 response.
Any ideas? I see the optimization assembly in the bin of the website under IIS.
It's using the 4.0 app pool and integrated mode.
I'm wondering if anyone has any ideas or suggestions?
Thanks
----- update based on questions -----
VS2012
targetFramework="4.5"
I also added some code into the view to show which modules were loaded and I can see the bundle module listed there.
BundleConfig is the default provided when using the Internet Application MVC4 project template.
The site is being deployed into the root. It's odd as when I set EnableOptimizations = true (due to running in debug mode via visual studio F5), it works perfect! I can navigate to content/css and it spits out the combined css.
I deploy it over and everything else works, but bundling!
I've just hit (and solved) this problem.
Make sure your bundle's virtual path can't be confused for an existing directory or actual file name. In my case, I'd coded it as:
bundles.Add(new ScriptBundle("~/bundles/main.js").Include( ...
But when I changed it to
bundles.Add(new ScriptBundle("~/bundles/main").Include( ...
it all started working.
Updated Answer on 11/17/2013
This is caused by the fact that the default MVC routing only handles * instead of * . *, i.e. IIS or IIS Express's applicationhost.config has the following:
<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />
So to workaround it, we can add the following to the web.config:
<system.webServer>
<handlers>
<add name="UrlRoutingHandler"
type="System.Web.Routing.UrlRoutingHandler,
System.Web, Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
path="/bundles/*"
verb="GET"/>
</handlers>
</system.webServer>
For more information, you can reference the following:
http://weblogs.asp.net/owscott/archive/2013/01/16/handing-mvc-paths-with-dots-in-the-path.aspx
ASP.NET MVC Url Route supporting (dot)
Old wrong answer:
Basically, DOT is generally not allowed in virtual path when IIS parse URLs.
This a Link mentioned the following URLScan AllowDotInPath parameter:
By default, this option is set to 0. If this option is set to 0, URLScan rejects any request that contains multiple periods (.). This prevents attempts to disguise requests for dangerous file name extensions by putting a safe file name extension in the path information or query string portion of the URL. For example, if this option is set to 1, URLScan might permit a request for http:// servername/BadFile.exe/SafeFile.htm because it interprets it as a request for an HTML page, when it is actually a request for an executable (.exe) file with the name of an HTML page in the PATH_INFO area. When this option is set to 0, URLScan may also deny requests for directories that contain periods.
Even I got the same error.
Adding <modules runAllManagedModulesForAllRequests="true" /> under <system.webServer> in web.config file solved the problem.
I had the same problem even with sample MVC application. I saw the default template bundles the style-sheet with css name which i guess IIS does not likes resulting in 404 error.
Changing the bundle name from css to APPCSS will resolve the issue for me.