Is it possible to use .asp extension for ASP.NET code? - c#

I want to ask if it's possible to configure server to work with .asp extensioned files as with ASP.NET pages. Or it's absolutly denied to not mix new code with old ASP?

You could place a *.asp file on your server that redirects to your final destination. I've had to do this a few times when we didn't want to break legacy hyperlinks.

Configuring Handler Mappings in IIS 7 would be the section that in theory you could specify which handler to use though this presumes you are using IIS 7.

It is not possible to mix both *.asp and *.aspx pages because the configuration differs for both and my suggestion is to convert everything to .asp /.aspx.

Related

Migrating / Redirecting parts of my ASP.NET site to new version

I am currently supporting an existing ASP.NET MVC web-site that was written by another developer. Many parts of the site were upgraded to more modern frameworks, and I would like to redirect users to the new site where possible. However, there are still some pages that will have to continue to be used on the old site until I can finish the migration.
The server is Windows Server 2008, IIS 7.0, .NET 4.5
Let's say the old URL is: https://www.companysite.com/
The new site is in a virtual directory at: https://www.companysite.com/thenewsite/
What is the best way to selectively redirect users to the new site, where I have those parts built, but also leave the old site accessible for the pages that are not yet transferred to the new design?
For example, I would like to redirect:
https://www.companysite.com/contracts/ to https://www.companysite.com/thenewsite/contracts/
But I can't redirect every path globally. For example:
https://www.companysite.com/shipping/ can NOT redirect to the new site yet, as I haven't built /thenewsite/shipping/ yet.
Here are some ideas I had, but I could use some guidance as to which one would be best:
Add a Response.Redirect or a html meta refresh to specific pages in the old site (Lots of effort)
Use the URL Rewrite module, with a custom rule (not sure how to do this)
Hopefully this makes sense. Any help or suggestions would be greatly appreciated.
For IIS 7.0 you will probably want to use https://www.iis.net/downloads/microsoft/url-rewrite
There are others and it depends on version of IIS. I used to use Helicon Rewrite and as an ISAPI plugin is was at the front of the request pipeline and that's important for performance, you don't want a request to get to a Controller before it's wrong, you'd want to catch it at the Routing at latest.
Whichever URL rewrite tool you use the key is to make them return the correct HTTP code.
A 301 redirect is a permanent redirect. It is cacheable and any bookmarks for this URL should be updated to point to the new URL. A 302 redirect is a temporary redirect. A 303 redirect is the same as a 302 except that the follow-up request is now explicitly changed to a GET request and no confirmation is required

how to achieve conditional app_offline.htm in asp .net IIS 7

I am going to upload new look of my site.my site is in ASP .NET , C#.
What i want that during my testing time the site should in Maintenance mode but i should be able to access the site.
So my question is can i have conditional app_offline.htm , so my site will be accessible from my IP and others will see app_offline page.
Please note I can change my IIS setting if required.
Sadly I dont think that is possible. App_offline.htm is a one-trick-pony and just takes the app offline.
You mention being able to amend IIS settings. Are you able to set up a second site within IIS and restrict access by IP address, therefore still having your existing site online.

Publishing asp.net single page to ftp server?

i'm trying to publish a webpage into my ftp server, thing is when i publish it and try to access it, the result is just pure code . How can i make it so that only the "design" of the asp file appears?
Thanks in advance,
Bruno Charters
How can i make it so that only the "design" of the asp file appears?
If all you want to appear in the browser is the "design" (meaning no server-side logic). Then all you'd really need is an HTML page. To do so:
copy the markup rendered by the .aspx file from the browsers source
paste the markup into an appropriately named .html/.htm file
upload the file to your server
If there is server-side logic then you'll need to upload the .aspx file to a server that has IIS and the appropriate version of the .NET Framework to run the page.
You will need to compile your code before you publish it. Compiling your code basically moves all the logic into the .dll file and leave only the HTML (well, at least). You will still need a Web Server with aspx processor, typically IIS.
You will need to point your Web Server to the folder you are uploading to.

jquery not working in asp.net mvc after publishing to localhost

I've built an mvc application which contains some jquery code. When I run the app from my ide, everything works perfectly. When I publish to the server and open the page, the jquery does not work. I get object expected errors.
i am not getting anything in the page,it shows error in loading dhtmlxsheduler.js
can you help me out
You issue is most likely due to the way you are defining the path to the JavaScript file you are loading.
Make sure that you use a relative path, and not an absolute path when calling the file source.
If you have runat="server" you can also use the ~ operator, which ASP.Net translates to your home directory.
Read more here http://msdn.microsoft.com/en-us/library/ms178116.aspx
Your links to the .js files are broken. See the source code of your pages in your browser, and check the tag's src attribute. It must be pointing to the wrong place.
My guess is removing ../ do you have iis express? or development server? or iis?
Or use a CDN like this one from Google:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

Is it possible to have a .NET route that maps to the same place as a directory?

I'm building a CMS using WebForms on .NET 4.0 and have the following route that allows URLs like www.mysite.com/about to be mapped to the Page.aspx page, which looks up the dynamic content.
routes.MapPageRoute("page", "{name}", "~/Page.aspx");
The problem is that I have a couple of folders in my project that are interfering with possible URLs. For example, I have a folder called "blog" where I store pages related to handling blog functionality, but if someone creates a page for their site called "blog" then navigating to www.mysite.com/blog gets the following error:
403 - Forbidden: Access is denied. You
do not have permission to view this
directory or page using the
credentials that you supplied.
Other similar URLs route correctly, but I think because .NET is identifying /blog as a physical location on the server it is denying directory access. Is there a way to tell IIS / .NET to only look for physical files instead of files and folders?
It looks like IIS is denying you access to the actual folder.
By default Routing is supposed to honor the file system. Though this can be turned off.

Categories