Showing posts with label umbracoRedirect. Show all posts
Showing posts with label umbracoRedirect. Show all posts

Thursday, August 17, 2017

Forcing Umbraco install your DB again

Introduction


When you install Umbraco nuget package for the first time, it will show you a pretty installation windows and then tries to install the DB for you. What if you want to do the same when publishing your code somewhere else? What is you don't care about your site content and just want the views/ templates like for your test/staging server?



Umbraco settings


In the web config> <appSettings> of your project there is a setting that tells Umbraco which version are you on.
<add key="umbracoConfigurationStatus" value="7.6.5" />

If you remove it from the config, Umbraco has no other way than installing the DataBase again, and you will see the installation page when you try to access to the page. But wait! why doesn't it do anything?
If you take a look at the developer tools of your browser you will see that one of the requests has been failed



This is the  Error:

{"Message":"An error has occurred.","ExceptionMessage":"Invalid object name 'umbracoUser'.","ExceptionType":"System.Data.SqlClient.SqlException","StackTrace":"   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n   at ....
So what is wrong?

Since we have set our connection string before, Umbraco thinks that there is a DB somewhere that has your User structure and tries to load your user. :)
Simply remove the Connection string and you will be fine 


Tuesday, July 5, 2016

umbracoRedirect The great hidden Property


I had a scenario that I wanted to redirect a page to another one in my Umbraco solution. I needed my page to be in my structure, but I didn't want it to show anything and I didn't want its url to be shown on the address bar. Then my friend Niels Damkjær showed me a good hidden feature in Umbraco.

There is no need to write code or do something hard. You just need to create a new field in your document type with alias umbracoRedirect and the editor has to be Content Picker. Thats all you need to do :) Something like this:


Then in your page you can select the tab for redirecting which is very cool. 
There is also a post in our Umbraco in here but you don't need to do it with those steps.


* After adding the field for the first time, it did not work for me, but when I restart my webserver it started to work fine.

* It uses the http 302 header to tel the browser to redirect to another page which is the temporary redirect command.