Running BlogEngine.NET with ASP.NET MVC under same website? - asp.net

Can anyone please help me with this?
I have a Windows 2008 server and MVC 2.0 site is hosted under IIS 7.0 root directory. The site works fine. I want to use the BlogEngine.NET with my site. For example if my mite name is http:// mysite.com (which is the root of IIS) and the blog should be http://mysite.com/blog/Default.aspx
Is this possible? Can I create a sub virtual directory within my root (where the MVC 2 app is hosted) and run the ASP.NET BlogEngine.Net in it?
Any ideas appreciated.

If you did decide to go with a single web application, you may find the following links useful:
http://redditech.wordpress.com/2009/02/16/howto-convert-blogenginenet-from-web-site-to-web-application-project/
http://www.upfromthesky.com/blog/post/2009/01/30/Integrate-BlogEngine-145-into-an-exisitng-website-%28VSNET-Website-Project%29.aspx
I've currently got a blog running at mysite.com/blog - it seems to be working fine, I'm just in the process of consolidating the membershipservices to work with my existing credentials.
There are important comments on the first link that you will probably need to do to get extensions working correctly.

Cut off the /blog app from MVC app using
<clear />
under
<system.web><pages><namespaces><clear />
For more details check this link.
http://www.dondraper.com/2010/02/how-to-stop-inheritance-of-webconfig-files/

Related

ASP.Net Website Routing

I have an ASP.NET website in framework 4.0
This website contains a subvirtual directory say directory1.
I want to add routing like when I type in browser
www.mydomain.com/funds it will get contents from www.mydomain.com/directory1
Example 2
**www.mydomain.com/funds/page1**
it will get contents from
**www.mydomain.com/directory1/page1**
URL in browser should remain **www.mydomain.com/funds/page1**
I have added reference of System.Web.Routing for this purpose. Initially tried with routes.MapPageRoute but there are no physical pages as directory1 is an wordpress website.
Any suggestions will be appreciated
Thank you
You may try URL Rewrite if you're using IIS for hosting website.

Asp.net app on IIS 8.5 subdomain redirection

I'm working on some app in asp.net mvc5. I have problems with redirection.
I'm using HttpContext.Current.Response.Redirect("www.google.com"); but the problem is that when I deploy on IIS i have web page on subdomain like somedomain.com/MyApp so when I use HttpContext.Current.Response.Redirect("www.google.com"); it creates link like somedomain.com/www.google.comso this is where the problem is. I don't now how to get rid of that subdomain ?
David
You need to qualify the protocol you are using, otherwise your addresss tring will be treated as a relative path.
For example:
HttpContext.Current.Response.Redirect("https://www.google.com")

Removing .aspx from URL with an IIS Version 6 server

I have a asp.net application that is running on a server that has IIS 6 on it. I want to set-up a redirect so that instead of my page reading www.google.com/About-Us.aspx it just has www.google.com/About-Us. I've seen in IIS7 where you can just write a rewrite into your web config file, but I'm not having much luck with what to do for IIS6. Has anyone else had this issue as well or know of a work around for this?
Thanks!
You should add URL Routing.
More about that (actually this is a solution you need) you can find HERE
Screenshot of page

IIS returns 404 for ASP.NET MVC3 file (.cshtml)

I have standard ASP.NET 4 application. Inside this application there are also few razor (e.g. test.cshtml) files. ASP.NET application works however if I point browser to /test file (without extension). IIS (static file handler) returns 404.
The same application and even the standalone .cshtml files are working on local machine (with IIS7.5/Win7) and a server with (IIS7.5/Win2008R2), however it does not work the server with IIS7.0/Win2008.
MVC3 is installed on both machines, app pools on both machines are .NET 4.0 integrated.
How the .cshtml handlers works? When the IIS decides to use static file handler and when the .cshtml handler? What else should I check?
EDIT:
Clarification - I am not actually using whole MVC framework, it is just like plain-old .ASPX or PHP file. No controllers, no routes, no 'views'. I am using it for a simple script in addition to old ASP.NET application.
I think it is not a programming issue, since it works on local computer, but rather a configuration issue - the IIS on the Win2008 server might not be configured properly.
EDIT2:
(Machines with IIS7.5 works, only machine with IIS7.0 does not work. But I am not sure whether it is a problem of IIS version.)
EDIT3:
On my local computer where it works, I have not set any routing. TheCodeKing and Keith suggested that I need to have a routing somewhere. Maybe yes, but it is not in my application. It might be set by default somewhere in IIS configuration.
Do you have any hints where this 'implicit' routing could be found?
EDIT4:
Note: On all computers there is HttpForbiddenHandler for *.cshtml, since you cannot download the cshtml file. And there is also the TransferRequestHandler for *.. (Both are enabled.)
EDIT5:
I have found that on the servers, where it is working, I need to have any .cshtml file in the web root. If I remove the .cshtml from the web root and try to invoke any from a subdirectory it will not work.
EDIT6:
I tried that on another two machines: one with IIS 7.5 and another with IIS 7.0. On IIS 7.5 it works (plain install no configuration), but on IIS 7.0 it does not work.
How to make it work on IIS 7.0?
Yay! After several days of struggling I've found it! :))
One way to make it work on IIS 7.0 is to enable runAllManagedModulesForAllRequests:
<modules runAllManagedModulesForAllRequests="true" />
(Although, on IIS 7.5 it works even with the default value runAllManagedModulesForAllRequests="false".)
Don't ask me why:) Maybe someone can explain that.
Not sure if this is your particular problem, but it sounds like ASP.NET Web Pages isn't running (MVC 3 and up depend on Web Pages for Razor and other things). Sometimes things can get installed in orders that mess up some configuration of ASP.NET and IIS, which in turn could make it so Web Pages isn't running and no cshtml file will get executed.
Try running aspnet_regiis /i to clean it all up.
There is an hotfix for IIS7.0 available at: http://support.microsoft.com/kb/980368
I installed it today on windows 2008 SP2 (which requires an OS restart).
The behavior in IIS 7.0 is now similar than IIS 7.5
It fixed the problem on my side / without forcing:
<modules runAllManagedModulesForAllRequests="true" />
This is a better approach than running all modules for any request (even on css/images/...) which would cause unnecessary overload.
Are you sure that IIS has sufficient permissions to access the file under the /test directory?
This could cause some silly issues as I've found.
If this is an asp.net 4.0 web application, you will need to manually set up routes, create the appropriate controller(s), and make sure that your views (.cshtml files) actually exist in the /Views/ControllerName folder.
I would also recommend setting up your project to use IISExpress in your development environment to more closely match your web server. It's a great help when debugging these sort of issues.
As you aren't using MVC, you would need to set up routing, or rewriting using IIS rewrite module to expect /test to resolve to /test.cshtml. You won't get this behaviour without it.
e.g. something like this in your application start.
routes.MapPageRoute(
"extension-less paths",
"{view}",
"~/{view}.cshtml"
);
cshtml can work, if you set a web.conf.
You can think it is a html but with razor syntax.

ASP.NET site inside a virtual directory

I am currently putting a new version of my site online. I would like to retain the old site (for purposes of read only access) and have been directed to place it within a subfolder inside the directory where the site use to live. e.g.
www.example.com needs to be moved to www.example.com/old and the new site needs to be moved to www.example.com
Unfortunately I get the classic ASP.NET error when attempting to piggy back sites that each have their own web config.
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.
How can I compeletly seperate off the new site and access it via. www.example.com/old without ASP.NET trying to trickle down through my directories and find the main sites web.config?
Thanks!
Giving the site its own AppPool should work.
You can do this by creating an AppPool and then on the virtual directory in IIS setting the app pool to your new one in the properties.
Make sure that the virtual directory is an application and not just a virtual directory.
You may try the following setting in the site contained in the virtual dir:
<location inheritInChildApplications="false">
Rick Strahl has the same problem and describes his experiences on his blog.
Didn't try it out myself, but found other blog articles which use it successfully with IIS6.
I've tried both creating a new App Pool on the site. That's didn't work -- same errors. I also added the inheritChildApplications attribute directive in my web.config. That didn't work either. The only way I have been able to achieve what I needed was to add a new subdomain in an entirely new folder and put a redirect to it in my www.example.com/old page to old.example.com.
It's not what I was looking to do, but it solved the issue.

Resources